Skip to content
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 exception when merging entries #5395

Merged
merged 1 commit into from
Oct 6, 2019
Merged

Fix exception when merging entries #5395

merged 1 commit into from
Oct 6, 2019

Conversation

tobiasdiez
Copy link
Member

The problem was that sourceChanged was invoked asynchronous and thus the information in the change event could be obsolete if another thread changed the underlying list in the meantime. Solution: run sourceChanged on the JavaFX thread but synchronously.
Fixes #5169.


  • Change in CHANGELOG.md described
  • Tests created for changes
  • Manually tested changed features in running JabRef
  • Screenshots added in PR description (for bigger UI changes)
  • Ensured that the git commit message is a good one
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)

The problem was that `sourceChanged` was invoked asynchronous and thus the information in the change event could be obsolete if another thread changed the underlying list in the meantime. Solution: run `sourceChanged` on the JavaFX thread but synchronously.
Fixes #5169.
@tobiasdiez tobiasdiez added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 6, 2019
Copy link
Member

@matthiasgeiger matthiasgeiger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice... tested it and works fine!

public UiThreadList(ObservableList<? extends T> source) {
super(source);
}

@Override
protected void sourceChanged(ListChangeListener.Change<? extends T> change) {
Platform.runLater(() -> fireChange(change));
if (Platform.isFxApplicationThread()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wow. This reads like an ugly hack. Good, that this works...

Would be nice if some comments were added:

  • Why can it happen that this method is called inside and outside the FxApplication thread?
  • Why can the fireChange method be run directly in the case of inside the FxApplication?
  • Why is CountDownLatch used and not something more different (it is used as Boolean flag)?

@koppor koppor merged commit ce9ef18 into master Oct 6, 2019
@koppor koppor deleted the fixMerge branch October 6, 2019 11:41
@koppor
Copy link
Member

koppor commented Oct 6, 2019

I merged to keep things moving. However, it would be nice if my code questions would lead no another PR adding comments on the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception when merging entries
3 participants