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

Spamming Ctrl+Z makes the JavaFXApplication crash #358

Closed
AlisCode opened this issue Sep 16, 2016 · 5 comments
Closed

Spamming Ctrl+Z makes the JavaFXApplication crash #358

AlisCode opened this issue Sep 16, 2016 · 5 comments

Comments

@AlisCode
Copy link

Hi,

Im using RichTextFX's CodeArea and noticed a weird bug.

Basically every shortcut works as expected : Ctrl+C, Ctrl+V... But spamming Ctrl+Z makes the JavaApplication crash.

Windows 10 x64, coding with NetBeans.
I'm using the RichTextFX FatJar version 0.6.10

Error code :
Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Unexpected change received.
Expected:
org.fxmisc.richtext.PlainTextChange@745f
Received:
org.fxmisc.richtext.PlainTextChange@74c3
at org.fxmisc.undo.impl.UndoManagerImpl.changeObserved(UndoManagerImpl.java:185)
at org.reactfx.util.QueuingStreamNotifications.lambda$head$274(NotificationAccumulator.java:217)
at org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:68)
at org.reactfx.SuspendableBase.resume(SuspendableBase.java:64)
at org.reactfx.CloseableOnceGuard.close(Guard.java:49)
at org.reactfx.MultiGuard.close(Guard.java:83)
at org.fxmisc.richtext.StyledTextArea.replace(StyledTextArea.java:731)
at org.fxmisc.richtext.StyledTextArea.replaceText(StyledTextArea.java:718)
at org.fxmisc.richtext.TextEditingArea.replaceText(TextEditingArea.java:204)
at org.fxmisc.richtext.EditActions.replaceSelection(EditActions.java:119)
at org.fxmisc.richtext.skin.StyledTextAreaBehavior.keyTyped(StyledTextAreaBehavior.java:281)
at org.fxmisc.wellbehaved.event.EventHandlerTemplate$On.lambda$null$23(EventHandlerTemplate.java:156)
at java.util.Optional.ifPresent(Optional.java:159)
at org.fxmisc.wellbehaved.event.EventHandlerTemplate$On.lambda$act$24(EventHandlerTemplate.java:155)
at org.fxmisc.wellbehaved.event.EventHandlerTemplate$Builder.lambda$create$21(EventHandlerTemplate.java:117)
at org.fxmisc.wellbehaved.event.EventHandlerTemplate.lambda$null$17(EventHandlerTemplate.java:39)
at org.fxmisc.wellbehaved.event.EventHandlerTemplate.lambda$bind$14(EventHandlerTemplate.java:18)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$KeyHandler.process(Scene.java:3964)
at javafx.scene.Scene$KeyHandler.access$1800(Scene.java:3910)
at javafx.scene.Scene.impl_processKeyEvent(Scene.java:2040)
at javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2501)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:216)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent$353(GlassViewEventHandler.java:247)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:246)
at com.sun.glass.ui.View.handleKeyEvent(View.java:546)
at com.sun.glass.ui.View.notifyKey(View.java:966)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)

Any fix ?

@JordanMartinez
Copy link
Contributor

JordanMartinez commented Sep 16, 2016

Unexpected change received.
Expected:
org.fxmisc.richtext.PlainTextChange@745f
Received:
org.fxmisc.richtext.PlainTextChange@74c3

It's not the spamming of Ctrl+Z that's the issue.

UndoFX works like so:

  1. The UndoManager gets notified every time the editable object gets changed. When it does, it stores that change in its linear queue .
  2. When the user undos/redos a change, the UndoManager will store that change in the variable expectedChange before applying it. By applying that change, the UndoManager now gets notified of a change. However, in this case, the received change is not a new one, so it should ignore it. It knows this by comparing the change it received with expectedChange. If they equal (a.equals(b)), then it does not add the received change to its queue since it's already in there. The position that points to the next redoable redo and undoable undo gets incremented forward by one.
  3. The issue you are experiencing arises when a unique situation happens: the user calls undo/redo, the change to be applied is stored away for comparison for later, and the change is applied. However, the applied change does not get emitted as a notification (I forget the exact reasons why this occurs....) to the UndoManager, which means expectedChange is not null and has a value. When the user edits the object (applies a new change), the UndoManager goes through the normal steps:
    • check if the expectedChange is null (this is a new change): false;
    • check if the received change equals the expectedChange (this is a redone/undone change): false, because expectedChange still holds the value of the previous undo/redo;
    • default to third case: throw your above exception.

We might have fixed this in the latest 0.7 release, but I can't remember. Could you compare the 0.6.10 release with the latest one's code?

@TomasMikula
Copy link
Member

This might be the same issue as #322.

@TomasMikula
Copy link
Member

If you can try 0.7-M2, if it doesn't solve the problem, it should at least give a better error message.

@JordanMartinez
Copy link
Contributor

This might be the same issue as #322.

Mm... I thought we had addressed this elsewhere...

@TomasMikula TomasMikula added this to the 0.7 milestone Sep 16, 2016
@ghost
Copy link

ghost commented Sep 19, 2016

Ok it's working well since the 0.7 thanks a lot for your reactivity !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants