In Mastodon beta-27 there is an exception when user runs "File > Save Project As...".
The stack trace:
Exception in thread "AWT-EventQueue-0" java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread
at java.awt.EventQueue.invokeAndWait(EventQueue.java:1331)
at java.awt.EventQueue.invokeAndWait(EventQueue.java:1324)
at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1353)
at org.mastodon.mamut.io.ProjectSaver.saveProjectAs(ProjectSaver.java:159)
at org.mastodon.mamut.io.ProjectActions.lambda$installAppActions$4(ProjectActions.java:114)
at org.scijava.ui.behaviour.util.RunnableAction.actionPerformed(RunnableAction.java:47)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
Why do we get thist exception?
The ProjectLoader.saveAs(...) is called from the AWT thread. But method's implementation expects the method not to be called from the AWT thread. Hence the exception.
Solution
This PR fixes the problem by creating a new "worker thread" which than executes the "save as" method.
@tinevez I'm not sure if you are happy with this solution. Feel free to solve the problem differently.
In Mastodon beta-27 there is an exception when user runs "File > Save Project As...".
The stack trace:
Why do we get thist exception?
The
ProjectLoader.saveAs(...)
is called from the AWT thread. But method's implementation expects the method not to be called from the AWT thread. Hence the exception.Solution
This PR fixes the problem by creating a new "worker thread" which than executes the "save as" method.
@tinevez I'm not sure if you are happy with this solution. Feel free to solve the problem differently.