From a8654a3aa55ebecba298366f4da3e50a1d857637 Mon Sep 17 00:00:00 2001 From: Matthias Arzt Date: Mon, 8 Jan 2024 13:37:58 +0100 Subject: [PATCH] Execute "Save Project" and "Save Project As" in a separate thread. --- .../org/mastodon/mamut/io/ProjectActions.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/mastodon/mamut/io/ProjectActions.java b/src/main/java/org/mastodon/mamut/io/ProjectActions.java index a34c8847b..38ec41563 100644 --- a/src/main/java/org/mastodon/mamut/io/ProjectActions.java +++ b/src/main/java/org/mastodon/mamut/io/ProjectActions.java @@ -110,8 +110,8 @@ public static void installGlobalActions( final Actions actions, final Context co */ public static void installAppActions( final Actions actions, final ProjectModel appModel, final Frame parentComponent ) { - final RunnableAction saveProjectAction = new RunnableAction( SAVE_PROJECT, () -> ProjectSaver.saveProject( appModel, parentComponent ) ); - final RunnableAction saveProjectAsAction = new RunnableAction( SAVE_PROJECT_AS, () -> ProjectSaver.saveProjectAs( appModel, parentComponent ) ); + final RunnableAction saveProjectAction = new RunnableAction( SAVE_PROJECT, runInNewThread( () -> ProjectSaver.saveProject( appModel, parentComponent ) ) ); + final RunnableAction saveProjectAsAction = new RunnableAction( SAVE_PROJECT_AS, runInNewThread( () -> ProjectSaver.saveProjectAs( appModel, parentComponent ) ) ); final RunnableAction importTgmmAction = new RunnableAction( IMPORT_TGMM, () -> ProjectImporter.importTgmmDataWithDialog( appModel, parentComponent ) ); final RunnableAction importSimiAction = new RunnableAction( IMPORT_TGMM, () -> ProjectImporter.importSimiDataWithDialog( appModel, parentComponent ) ); final RunnableAction exportMamutAction = new RunnableAction( EXPORT_MAMUT, () -> ProjectExporter.exportMamut( appModel, parentComponent ) ); @@ -123,6 +123,22 @@ public static void installAppActions( final Actions actions, final ProjectModel actions.namedAction( exportMamutAction, EXPORT_MAMUT_KEYS ); } + private static Runnable runInNewThread( Runnable o ) + { + return () -> { + new Thread( () -> { + try + { + o.run(); + } + catch ( Throwable t ) + { + t.printStackTrace(); + } + } ).start(); + }; + } + /* * Command descriptions for all provided commands */