-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Saving changes and exiting application #4729
Conversation
Fixes #4728 When the user clicks _Save changes_ option, the status of saving is not shown unlike before. I am not sure what might be the cause of that.
The |
I don't have the code at hands, but this could be a reason. You could debug and see where the save happens and when the instance should be closed |
Okay, so this is what I think is happening. The SaveDatabaseAction class' doSave() updates UI on JavaFxThread, however the call to I placed a lock before calling tearDownJabRefFrame, hence, blocking that thread. But the code under doSave() method, wasn't executed, shouldn't they be running on separate threads? |
I'll take a look at it tomorrow
Yash Kothari <notifications@github.com> schrieb am Mi., 6. März 2019, 19:09:
… Okay, so this is what I think is happening.
The SaveDatabaseAction class' doSave()
<https://github.com/JabRef/jabref/blob/master/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java#L141>
updates UI on *JavaFxThread*, however the call to tearDownJabRefFrame
executes before that and a blank window is shown instead of the UI.
I placed a lock before calling tearDownJabRefFrame
<https://github.com/JabRef/jabref/blob/master/src/main/java/org/jabref/gui/JabRefFrame.java#L516>,
hence, blocking that thread. But the code under doSave()
<https://github.com/JabRef/jabref/blob/master/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java#L141>
method, wasn't executed, shouldn't they be running on separate threads?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4729 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AATi5IUO25BN99fnkHBJeATCdwABP-JYks5vUARIgaJpZM4bhHoJ>
.
|
@@ -1334,10 +1334,10 @@ private boolean confirmClose(BasePanel panel) { | |||
} catch (Throwable ex) { | |||
return false; | |||
} | |||
} else { |
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.
Your idea here was good, but not completely right:
You actually had to return true for the case that the save was okay:
if (response.isPresent() && response.get().equals(saveChanges)) {
// The user wants to save.
try {
SaveDatabaseAction saveAction = new SaveDatabaseAction(panel, Globals.prefs);
if (!saveAction.save()) {
// The action was either canceled or unsuccessful.
output(Localization.lang("Unable to save library"));
return false;
} else {
return true; //here the save was sucessful
}
} catch (Throwable ex) {
return false;
}
}
return false;
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.
And while you are there, please add a LOGGER.errror statement for the exception
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.
I agree, that is a better place to put the return true statement. However, wouldn't both work the same way?
In case the save fails, it returns false, or if an exception occurs it is caught and again returns false. If none of these cases occur, it returns true.
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.
Even easier: you can remove all return false statements (except the one at the bottom of the function) and only have the return true in the else case. And I would switch the if/else for saveDatabase to
if(saveAction.save)`
{
return true;
{
else
{ output....
}
So when no return true is called, the function will automatically return false per last statement.
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.
But we would also have to take care of the case when the saveAction.save
throws an exception.
Also, the last statement could return true as well if the user clicked cancel, but that is already taken care of.
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.
I'll make the appropriate changes and push the code.
} | ||
return false; | ||
return !response.isPresent() || !response.get().equals(cancel); |
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.
Here it is sufficient to return simply false, because you do the check already as the very first. And the user can only click save or cancel.
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.
Aren't there 3 options, Save changes, Discard changes and Return to JabRef?
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.
If only return false is used, then Discard changes will not quit the application, is that the intended behavior?
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.
You are right. Forgot that there is a third option
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.
lgtm
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.
I'm not sure if I understand the changes correctly. (see remarks below)
As a solution, I would suggest to remove the runInJavaFXThread
call in the doSave
method (this should be done either way).
} catch (Throwable ex) { | ||
return false; | ||
LOGGER.error("A problem occurred when saving the file", ex); |
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.
Please also add a dialogService.showError()
call, because we also want to notify the user that we were unable to save the library.
I have a doubt, since the |
Please remove the runInJavaFXThread call only when the doSave is called from GUI methods. It might that the doSave could be called from a background thread which will result in a not on fx thread exception. |
Will adding a new method |
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.
I had a (quick) look and couldn't find a caller invoking the save method from a background task. But could be that I overlooked something (there are quite a few indirect calls to this method). So I think it is safe to remove it (and if not than the method should be refactored anyway).
…erbibtexkey * upstream/master: (827 commits) [#4306] Disable renaming (#4727) Feature: implement search filter in show preferences (#4759) Enable import button only if entry selected (#4761) Improve Remote messaging (#4760) Add changelog entry for #4520 Modifications to improve contrast of UI elements (#4758) Rework external changes dialog in JavaFX (#4693) Changes the title of Group Dialog to Add subgroup when adding a new subgroup (#4757) Optimize data fetching (#4520) Adds a browse button next to the path text field for aux-based groups (#4743) Saving changes and exiting application (#4729) Code optimized and created a reusable method to get writer output (#4750) Bump mvvmfx from 1.7.0 to 1.8.0 (#4747) Bump guava from 27.0.1-jre to 27.1-jre (#4748) Bump mvvmfx-validation from 1.7.0 to 1.8.0 (#4749) Remove obsolete swing components in Preferences and OpenOffice (#4740) Move library specific key pattern dialog call to library menu (#4744) Revert "Revert "Fix: bibkey generated does not handle diacritics" (#4741)" (#4742) Revert "Fix: bibkey generated does not handle diacritics" (#4741) Rename method to removeUnwantedCharacters ...
906cd6d Create technische-universitat-dresden-linguistik-author-date (#4730) 607a056 Create ifao-publications.csl (#4731) 5a65f50 remove et-al settings for bibliography for PVS (#4735) 4a145d4 Create current-opinion-in-endocrinology-diabetes-and-obesity.csl (#4734) d70c2a4 Add chapter section in bibliography (#4732) 366dbc1 Create economic-history-review.csl (#4643) 7069ddc Create the-open-university-harvard-s390-modules.csl (#4711) a789973 Chicago: Uppercase "Presentated at" if no `genre` (#4729) git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 906cd6d
906cd6d Create technische-universitat-dresden-linguistik-author-date (JabRef#4730) 607a056 Create ifao-publications.csl (JabRef#4731) 5a65f50 remove et-al settings for bibliography for PVS (JabRef#4735) 4a145d4 Create current-opinion-in-endocrinology-diabetes-and-obesity.csl (JabRef#4734) d70c2a4 Add chapter section in bibliography (JabRef#4732) 366dbc1 Create economic-history-review.csl (JabRef#4643) 7069ddc Create the-open-university-harvard-s390-modules.csl (JabRef#4711) a789973 Chicago: Uppercase "Presentated at" if no `genre` (JabRef#4729) 143464e Fix comma before et al. for the-oncologist.csl (JabRef#4724) 3b331b6 fixed bug with "near-note" position univ.-bordeaux-ecole-doctorale-de… (JabRef#4719) b2c0c1e APA: in-text title in title-case (JabRef#4725) 88c68d2 Fix et-al and indetation settings for mammalia.csl (JabRef#4717) 05940a2 Update the-febs-journal.csl (JabRef#4720) 1d77ba8 Request for review and assessment of the repa.csl (JabRef#4698) 76b4be5 Update isnad.csl (JabRef#4716) f709c84 Update isnad-dipnotlu.csl (JabRef#4715) 45d7655 Create mammalia.csl (JabRef#4714) eb333ca Update society-for-american-archaeology.csl (JabRef#4710) d944e71 Update masarykova-univerzita-pravnicka-fakulta.csl (JabRef#4712) 5e34eb1 Update animal-welfare.csl (JabRef#4713) 06785fa Update le-tapuscrit-author-date.csl (JabRef#4708) ada5282 Update norois.csl (JabRef#4707) git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 906cd6d
906cd6d Create technische-universitat-dresden-linguistik-author-date (JabRef#4730) 607a056 Create ifao-publications.csl (JabRef#4731) 5a65f50 remove et-al settings for bibliography for PVS (JabRef#4735) 4a145d4 Create current-opinion-in-endocrinology-diabetes-and-obesity.csl (JabRef#4734) d70c2a4 Add chapter section in bibliography (JabRef#4732) 366dbc1 Create economic-history-review.csl (JabRef#4643) 7069ddc Create the-open-university-harvard-s390-modules.csl (JabRef#4711) a789973 Chicago: Uppercase "Presentated at" if no `genre` (JabRef#4729) 143464e Fix comma before et al. for the-oncologist.csl (JabRef#4724) 3b331b6 fixed bug with "near-note" position univ.-bordeaux-ecole-doctorale-de… (JabRef#4719) b2c0c1e APA: in-text title in title-case (JabRef#4725) 88c68d2 Fix et-al and indetation settings for mammalia.csl (JabRef#4717) 05940a2 Update the-febs-journal.csl (JabRef#4720) 1d77ba8 Request for review and assessment of the repa.csl (JabRef#4698) 76b4be5 Update isnad.csl (JabRef#4716) f709c84 Update isnad-dipnotlu.csl (JabRef#4715) 45d7655 Create mammalia.csl (JabRef#4714) eb333ca Update society-for-american-archaeology.csl (JabRef#4710) d944e71 Update masarykova-univerzita-pravnicka-fakulta.csl (JabRef#4712) 5e34eb1 Update animal-welfare.csl (JabRef#4713) 06785fa Update le-tapuscrit-author-date.csl (JabRef#4708) ada5282 Update norois.csl (JabRef#4707) git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 906cd6d
906cd6d Create technische-universitat-dresden-linguistik-author-date (JabRef#4730) 607a056 Create ifao-publications.csl (JabRef#4731) 5a65f50 remove et-al settings for bibliography for PVS (JabRef#4735) 4a145d4 Create current-opinion-in-endocrinology-diabetes-and-obesity.csl (JabRef#4734) d70c2a4 Add chapter section in bibliography (JabRef#4732) 366dbc1 Create economic-history-review.csl (JabRef#4643) 7069ddc Create the-open-university-harvard-s390-modules.csl (JabRef#4711) a789973 Chicago: Uppercase "Presentated at" if no `genre` (JabRef#4729) 143464e Fix comma before et al. for the-oncologist.csl (JabRef#4724) 3b331b6 fixed bug with "near-note" position univ.-bordeaux-ecole-doctorale-de… (JabRef#4719) b2c0c1e APA: in-text title in title-case (JabRef#4725) 88c68d2 Fix et-al and indetation settings for mammalia.csl (JabRef#4717) 05940a2 Update the-febs-journal.csl (JabRef#4720) 1d77ba8 Request for review and assessment of the repa.csl (JabRef#4698) 76b4be5 Update isnad.csl (JabRef#4716) f709c84 Update isnad-dipnotlu.csl (JabRef#4715) 45d7655 Create mammalia.csl (JabRef#4714) eb333ca Update society-for-american-archaeology.csl (JabRef#4710) d944e71 Update masarykova-univerzita-pravnicka-fakulta.csl (JabRef#4712) 5e34eb1 Update animal-welfare.csl (JabRef#4713) 06785fa Update le-tapuscrit-author-date.csl (JabRef#4708) ada5282 Update norois.csl (JabRef#4707) git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 906cd6d
906cd6d Create technische-universitat-dresden-linguistik-author-date (JabRef#4730) 607a056 Create ifao-publications.csl (JabRef#4731) 5a65f50 remove et-al settings for bibliography for PVS (JabRef#4735) 4a145d4 Create current-opinion-in-endocrinology-diabetes-and-obesity.csl (JabRef#4734) d70c2a4 Add chapter section in bibliography (JabRef#4732) 366dbc1 Create economic-history-review.csl (JabRef#4643) 7069ddc Create the-open-university-harvard-s390-modules.csl (JabRef#4711) a789973 Chicago: Uppercase "Presentated at" if no `genre` (JabRef#4729) 143464e Fix comma before et al. for the-oncologist.csl (JabRef#4724) 3b331b6 fixed bug with "near-note" position univ.-bordeaux-ecole-doctorale-de… (JabRef#4719) b2c0c1e APA: in-text title in title-case (JabRef#4725) 88c68d2 Fix et-al and indetation settings for mammalia.csl (JabRef#4717) 05940a2 Update the-febs-journal.csl (JabRef#4720) 1d77ba8 Request for review and assessment of the repa.csl (JabRef#4698) 76b4be5 Update isnad.csl (JabRef#4716) f709c84 Update isnad-dipnotlu.csl (JabRef#4715) 45d7655 Create mammalia.csl (JabRef#4714) eb333ca Update society-for-american-archaeology.csl (JabRef#4710) d944e71 Update masarykova-univerzita-pravnicka-fakulta.csl (JabRef#4712) 5e34eb1 Update animal-welfare.csl (JabRef#4713) git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 906cd6d
906cd6d Create technische-universitat-dresden-linguistik-author-date (JabRef#4730) 607a056 Create ifao-publications.csl (JabRef#4731) 5a65f50 remove et-al settings for bibliography for PVS (JabRef#4735) 4a145d4 Create current-opinion-in-endocrinology-diabetes-and-obesity.csl (JabRef#4734) d70c2a4 Add chapter section in bibliography (JabRef#4732) 366dbc1 Create economic-history-review.csl (JabRef#4643) 7069ddc Create the-open-university-harvard-s390-modules.csl (JabRef#4711) a789973 Chicago: Uppercase "Presentated at" if no `genre` (JabRef#4729) 143464e Fix comma before et al. for the-oncologist.csl (JabRef#4724) 3b331b6 fixed bug with "near-note" position univ.-bordeaux-ecole-doctorale-de… (JabRef#4719) b2c0c1e APA: in-text title in title-case (JabRef#4725) 88c68d2 Fix et-al and indetation settings for mammalia.csl (JabRef#4717) 05940a2 Update the-febs-journal.csl (JabRef#4720) 1d77ba8 Request for review and assessment of the repa.csl (JabRef#4698) 76b4be5 Update isnad.csl (JabRef#4716) f709c84 Update isnad-dipnotlu.csl (JabRef#4715) 45d7655 Create mammalia.csl (JabRef#4714) eb333ca Update society-for-american-archaeology.csl (JabRef#4710) d944e71 Update masarykova-univerzita-pravnicka-fakulta.csl (JabRef#4712) 5e34eb1 Update animal-welfare.csl (JabRef#4713) 06785fa Update le-tapuscrit-author-date.csl (JabRef#4708) ada5282 Update norois.csl (JabRef#4707) git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 906cd6d
906cd6d Create technische-universitat-dresden-linguistik-author-date (JabRef#4730) 607a056 Create ifao-publications.csl (JabRef#4731) 5a65f50 remove et-al settings for bibliography for PVS (JabRef#4735) 4a145d4 Create current-opinion-in-endocrinology-diabetes-and-obesity.csl (JabRef#4734) d70c2a4 Add chapter section in bibliography (JabRef#4732) 366dbc1 Create economic-history-review.csl (JabRef#4643) 7069ddc Create the-open-university-harvard-s390-modules.csl (JabRef#4711) a789973 Chicago: Uppercase "Presentated at" if no `genre` (JabRef#4729) 143464e Fix comma before et al. for the-oncologist.csl (JabRef#4724) 3b331b6 fixed bug with "near-note" position univ.-bordeaux-ecole-doctorale-de… (JabRef#4719) b2c0c1e APA: in-text title in title-case (JabRef#4725) 88c68d2 Fix et-al and indetation settings for mammalia.csl (JabRef#4717) 05940a2 Update the-febs-journal.csl (JabRef#4720) 1d77ba8 Request for review and assessment of the repa.csl (JabRef#4698) 76b4be5 Update isnad.csl (JabRef#4716) f709c84 Update isnad-dipnotlu.csl (JabRef#4715) 45d7655 Create mammalia.csl (JabRef#4714) eb333ca Update society-for-american-archaeology.csl (JabRef#4710) d944e71 Update masarykova-univerzita-pravnicka-fakulta.csl (JabRef#4712) 5e34eb1 Update animal-welfare.csl (JabRef#4713) 06785fa Update le-tapuscrit-author-date.csl (JabRef#4708) ada5282 Update norois.csl (JabRef#4707) git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 906cd6d
906cd6d Create technische-universitat-dresden-linguistik-author-date (JabRef#4730) 607a056 Create ifao-publications.csl (JabRef#4731) 5a65f50 remove et-al settings for bibliography for PVS (JabRef#4735) 4a145d4 Create current-opinion-in-endocrinology-diabetes-and-obesity.csl (JabRef#4734) d70c2a4 Add chapter section in bibliography (JabRef#4732) 366dbc1 Create economic-history-review.csl (JabRef#4643) 7069ddc Create the-open-university-harvard-s390-modules.csl (JabRef#4711) a789973 Chicago: Uppercase "Presentated at" if no `genre` (JabRef#4729) git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 906cd6d
906cd6d Create technische-universitat-dresden-linguistik-author-date (JabRef#4730) 607a056 Create ifao-publications.csl (JabRef#4731) 5a65f50 remove et-al settings for bibliography for PVS (JabRef#4735) 4a145d4 Create current-opinion-in-endocrinology-diabetes-and-obesity.csl (JabRef#4734) d70c2a4 Add chapter section in bibliography (JabRef#4732) 366dbc1 Create economic-history-review.csl (JabRef#4643) 7069ddc Create the-open-university-harvard-s390-modules.csl (JabRef#4711) a789973 Chicago: Uppercase "Presentated at" if no `genre` (JabRef#4729) 143464e Fix comma before et al. for the-oncologist.csl (JabRef#4724) 3b331b6 fixed bug with "near-note" position univ.-bordeaux-ecole-doctorale-de… (JabRef#4719) b2c0c1e APA: in-text title in title-case (JabRef#4725) 88c68d2 Fix et-al and indetation settings for mammalia.csl (JabRef#4717) 05940a2 Update the-febs-journal.csl (JabRef#4720) 1d77ba8 Request for review and assessment of the repa.csl (JabRef#4698) 76b4be5 Update isnad.csl (JabRef#4716) f709c84 Update isnad-dipnotlu.csl (JabRef#4715) 45d7655 Create mammalia.csl (JabRef#4714) eb333ca Update society-for-american-archaeology.csl (JabRef#4710) d944e71 Update masarykova-univerzita-pravnicka-fakulta.csl (JabRef#4712) 5e34eb1 Update animal-welfare.csl (JabRef#4713) 06785fa Update le-tapuscrit-author-date.csl (JabRef#4708) ada5282 Update norois.csl (JabRef#4707) git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 906cd6d
906cd6d Create technische-universitat-dresden-linguistik-author-date (JabRef#4730) 607a056 Create ifao-publications.csl (JabRef#4731) 5a65f50 remove et-al settings for bibliography for PVS (JabRef#4735) 4a145d4 Create current-opinion-in-endocrinology-diabetes-and-obesity.csl (JabRef#4734) d70c2a4 Add chapter section in bibliography (JabRef#4732) 366dbc1 Create economic-history-review.csl (JabRef#4643) 7069ddc Create the-open-university-harvard-s390-modules.csl (JabRef#4711) a789973 Chicago: Uppercase "Presentated at" if no `genre` (JabRef#4729) 143464e Fix comma before et al. for the-oncologist.csl (JabRef#4724) 3b331b6 fixed bug with "near-note" position univ.-bordeaux-ecole-doctorale-de… (JabRef#4719) b2c0c1e APA: in-text title in title-case (JabRef#4725) 88c68d2 Fix et-al and indetation settings for mammalia.csl (JabRef#4717) 05940a2 Update the-febs-journal.csl (JabRef#4720) 1d77ba8 Request for review and assessment of the repa.csl (JabRef#4698) 76b4be5 Update isnad.csl (JabRef#4716) f709c84 Update isnad-dipnotlu.csl (JabRef#4715) 45d7655 Create mammalia.csl (JabRef#4714) eb333ca Update society-for-american-archaeology.csl (JabRef#4710) d944e71 Update masarykova-univerzita-pravnicka-fakulta.csl (JabRef#4712) 5e34eb1 Update animal-welfare.csl (JabRef#4713) 06785fa Update le-tapuscrit-author-date.csl (JabRef#4708) ada5282 Update norois.csl (JabRef#4707) git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 906cd6d
906cd6d Create technische-universitat-dresden-linguistik-author-date (JabRef#4730) 607a056 Create ifao-publications.csl (JabRef#4731) 5a65f50 remove et-al settings for bibliography for PVS (JabRef#4735) 4a145d4 Create current-opinion-in-endocrinology-diabetes-and-obesity.csl (JabRef#4734) d70c2a4 Add chapter section in bibliography (JabRef#4732) 366dbc1 Create economic-history-review.csl (JabRef#4643) 7069ddc Create the-open-university-harvard-s390-modules.csl (JabRef#4711) a789973 Chicago: Uppercase "Presentated at" if no `genre` (JabRef#4729) git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 906cd6d
906cd6d Create technische-universitat-dresden-linguistik-author-date (JabRef#4730) 607a056 Create ifao-publications.csl (JabRef#4731) 5a65f50 remove et-al settings for bibliography for PVS (JabRef#4735) 4a145d4 Create current-opinion-in-endocrinology-diabetes-and-obesity.csl (JabRef#4734) d70c2a4 Add chapter section in bibliography (JabRef#4732) 366dbc1 Create economic-history-review.csl (JabRef#4643) 7069ddc Create the-open-university-harvard-s390-modules.csl (JabRef#4711) a789973 Chicago: Uppercase "Presentated at" if no `genre` (JabRef#4729) git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 906cd6d
Fixes #4728
When the user clicks Save changes option, the status of
saving is not shown unlike before. I am not sure what might be
the cause of that.