-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Remove listeners in RedoAction for memory efficiency #11839
base: main
Are you sure you want to change the base?
Conversation
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 code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
You can check review dog's comments at the tab "Files changed" of your pull request.
Checkstyle says
|
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 code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
You can check review dog's comments at the tab "Files changed" of your pull request.
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.
Minor formatting changes requested. Otherwise LGTM.
Thank you for your contribution!
P.S. Do mark the mandatory checks that you have completed in the PR description when you file one (the ones that apply).
* @implNote See also {@link UndoAction} | ||
* @implNote | ||
* See | ||
* also | ||
* {@link | ||
* UndoAction} |
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.
Revert this
} catch (CannotRedoException ex) { | ||
} catch ( | ||
CannotRedoException 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 fix the catch indent (not your fault, IntelliJ does this by default when we format the document).
activeLibraryTab.ifPresent(libraryTab -> | ||
this.executable.bind(libraryTab.getUndoManager().getRedoableProperty())); | ||
}); | ||
|
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.
This empty line is not necessary, is it?
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.
actually this empty line is for exists to separate lines 30 and 32 from each other. But I can remove.
@subhramit We should test this. This PR implements both suggestions of you (#11809 (comment)). I think, one needs to open 5 to 10 libraries, switch tabs back and forth, modifying the library and see if undo/redo is enabled properly. @melisolmez For consistency reasons, this patch also nees to be ported to the UndoAction. Undo is the twin of Redo. --> https://github.com/JabRef/jabref/blob/8412e651b671a427c828924ce5698eb4c32f269d/src/main/java/org/jabref/gui/undo/UndoAction.java |
Okey. Should I send it to the same branch? |
Actually, suggestion 1 was to conditionally but explicitly use What is probably confusing - use of |
this.executable.bind(libraryTab.getUndoManager().getRedoableProperty())); | ||
}); | ||
|
||
oldValue.ifPresent(libraryTab -> this.executable.unbind()); |
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.
Thinking a bit more, I am a bit concerned about the order of operations here.
Case 1:
State A->B - change detected, bind to B, unbind if oldValue is not null. After this,
State B->A - change detected, bind to A (not needed), unbind if B (oldvalue) is not null, which is true, so unbind (this is fine).
Case 2:
State A->B - change detected, bind to B, unbind if oldValue is not null. After this,
State B->C - change detected, bind to C, unbind if B is not null (which is true) - thus executable is not bound.
@Siedlerchr would it be better if we don't unbind at all here? Or is this alright as LibraryTab can never have a third state "C"?
Undo/Redo are part of the same component, IMO this PR should handle both of them. |
fixes #11809
jabref/src/main/java/org/jabref/gui/undo/RedoAction.java
Approach used: WeakChangeListener
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)