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

Fix "File > Save Project As...". #273

Merged
merged 1 commit into from
Jan 8, 2024
Merged

Fix "File > Save Project As...". #273

merged 1 commit into from
Jan 8, 2024

Conversation

maarzt
Copy link
Contributor

@maarzt maarzt commented Jan 8, 2024

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.

@maarzt maarzt requested a review from tinevez January 8, 2024 12:58
@maarzt maarzt changed the base branch from master to dev January 8, 2024 13:01
@tinevez tinevez merged commit a8654a3 into dev Jan 8, 2024
1 check passed
@tinevez tinevez deleted the fix-save-as branch January 8, 2024 16:41
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

Successfully merging this pull request may close these issues.

2 participants