-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix randomly blank currency box upon opening the Offer screen #7259
Fix randomly blank currency box upon opening the Offer screen #7259
Conversation
When clicking Create Buy/Sell Offer, or Edit/Duplicate/Clone an existing offer, randomly the initial display of "Currency" associated with the initially selected payment method was displayed as blank. This seems to have been caused by scheduling the selection of the initial payment method combobox selection to happen on a different thread rather than immediately selecting it (apparently, sometimes the secondard event to select the currency gets lost).
@@ -258,7 +258,7 @@ protected void doActivate() { | |||
|
|||
currencyComboBox.getSelectionModel().select(model.getTradeCurrency()); | |||
paymentAccountsComboBox.setItems(getPaymentAccounts()); | |||
UserThread.execute(() -> paymentAccountsComboBox.getSelectionModel().select(model.getPaymentAccount())); | |||
paymentAccountsComboBox.getSelectionModel().select(model.getPaymentAccount()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this change avoid that issue? The UserThread.execute schedules the execution to the next render frame and serves as a small delay which often fixed UI synchronisation issues.
Yes, it does seem to have fixed the issue. From all the test scenarios that I could think of, it did not seem to break anything! I'm aware what UserThread.execute() does, as well as that it was used uncharacteristically here (which was suspicious and warranted further caution). I also do not understand why this change makes a difference like it does (for me). Most places are just fine doing a combobox select() directly, so would be interested if the dev who originally added that is still available to contact, and if he/she recalls why they chose to put userThread.execute() there? |
The JavaFX framework works basically to queue up tasks and then execute them at a frame-rate based interval (all single thread). With UserThread.execute() we delegate some runnable code to that queue (using Platform::runlater under the hood if its a UI app). The main usage is when code is running on a non UI thread and we apply it to UI components which would then cause an exception as UI components must be called from the UI thread. |
JavaFX isn't the only library that has such oddities; I've definitely seen this at times in pretty much every UI library, including MUI and Windows SDK itself. This could even be a bug in JavaFX itself. I'm also aware of multithreading issues and how the main event loop works, etc. from other systems, and I assumed as much was the same for JavaFX. My personal assessment of the unusual UserThread.execute() causing this issue was indeed that it was a "cheap hack" (as you put it) that someone had resorted to at one point. Removal of UserThread does seem to resolve the issue in all my testing, but it's up to you if you care to fix this minor blemish with this pull request. Otherwise, the bug can remain, it's just a minor inconvenience that users can work around fairly easily. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
When clicking Create Buy/Sell Offer, or Edit/Duplicate/Clone an existing offer, randomly the initial display of "Currency" associated with the initially selected payment method was displayed as blank. This seems to have been caused by scheduling the selection of the initial payment method combobox selection to happen on a different thread rather than immediately selecting it (apparently, sometimes the secondary event to select the currency gets lost).