-
-
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
Changes from 1 commit
f4d8e09
9c55ffa
b527768
e6ba7a8
b0b8bd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1334,10 +1334,10 @@ private boolean confirmClose(BasePanel panel) { | |
} catch (Throwable ex) { | ||
return false; | ||
} | ||
} else { | ||
return !response.isPresent() || !response.get().equals(cancel); | ||
// Exit. | ||
return true; | ||
} | ||
return false; | ||
return !response.isPresent() || !response.get().equals(cancel); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. You are right. Forgot that there is a third option |
||
} | ||
|
||
private void closeTab(BasePanel panel) { | ||
|
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:
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
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.