itemis / gef-mindmap-tutorial

GEF Mindmap Tutorial
GNU General Public License v3.0
9 stars 4 forks source link

Endless NPE on arrow keys #2

Open frankbenoit opened 5 years ago

frankbenoit commented 5 years ago

When i start the SimpleMindMapApplication and i use the keyboard arrow keys, left/right the view is moving left right. But after some key presses, the console prints endless stacktraces.

Is this an error in the application or in GEF? I use GEF 5.0.1

....
    at java.lang.Thread.run(Thread.java:745)
java.lang.NullPointerException
    at org.eclipse.gef.mvc.fx.handlers.PanOnStrokeHandler.updateScrollPosition(PanOnStrokeHandler.java:272)
    at org.eclipse.gef.mvc.fx.handlers.PanOnStrokeHandler$1.handle(PanOnStrokeHandler.java:163)
    at javafx.animation.AnimationTimer$AnimationTimerReceiver.lambda$handle$484(AnimationTimer.java:57)
    at java.security.AccessController.doPrivileged(Native Method)
    at javafx.animation.AnimationTimer$AnimationTimerReceiver.handle(AnimationTimer.java:56)
    at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:357)
    at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:267)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:506)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:490)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$404(QuantumToolkit.java:319)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    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)
java.lang.NullPointerException
    at org.eclipse.gef.mvc.fx.handlers.PanOnStrokeHandler.updateScrollPosition(PanOnStrokeHandler.java:272)
    at org.eclipse.gef.mvc.fx.handlers.PanOnStrokeHandler$1.handle(PanOnStrokeHandler.java:163)
    at javafx.animation.AnimationTimer$AnimationTimerReceiver.lambda$handle$484(AnimationTimer.java:57)
    at java.security.AccessController.doPrivileged(Native Method)
    at javafx.animation.AnimationTimer$AnimationTimerReceiver.handle(AnimationTimer.java:56)
    at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:357)
    at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:267)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:506)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:490)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$404(QuantumToolkit.java:319)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    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)
java.lang.NullPointerException
    at org.eclipse.gef.mvc.fx.handlers.PanOnStrokeHandler.updateScrollPosition(PanOnStrokeHandler.java:272)
    at org.eclipse.gef.mvc.fx.handlers.PanOnStrokeHandler$1.handle(PanOnStrokeHandler.java:163)
    at javafx.animation.AnimationTimer$AnimationTimerReceiver.lambda$handle$484(AnimationTimer.java:57)
    at java.security.AccessController.doPrivileged(Native Method)
    at javafx.animation.AnimationTimer$AnimationTimerReceiver.handle(AnimationTimer.java:56)
    at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:357)
    at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:267)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:506)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:490)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$404(QuantumToolkit.java:319)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    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)
....
mwienand commented 5 years ago

Thank you for reporting the issue!

I was looking into it and this should be a bug in GEF that only happens when panning is aborted due to the internal AnimationTimer not being stopped. The timer calls updateScrollPosition() leading to the exception. I created Bugzilla https://bugs.eclipse.org/bugs/show_bug.cgi?id=541744 to keep track of the issue.

In order to resolve the issue, we need to stop the AnimationTimer when the panning handler is aborted.

However, I wonder why the handler is aborted without the viewer losing focus. So you would need to verify if panning works for you or if it stops randomly (due to the handler being aborted).

miklossy commented 5 years ago

I recorded a screencast that reproduces the problem: screencast

nakag commented 5 years ago

I had a same issue. It may be focus problem. In my case, it was fixed by this commit.

https://github.com/nakag/gef5.mvc.examples/commit/36c8d3461d0fc6fea87b128586962f19393ed7f8#diff-02407d1b3cb61fdc2e841a0ea3dd0e8cR90