diff --git a/src/main/java/de/thomas_oster/visicut/gui/VisicutApp.java b/src/main/java/de/thomas_oster/visicut/gui/VisicutApp.java index 5ae824f8..be829597 100644 --- a/src/main/java/de/thomas_oster/visicut/gui/VisicutApp.java +++ b/src/main/java/de/thomas_oster/visicut/gui/VisicutApp.java @@ -371,21 +371,24 @@ else if ("--add".equals(s)) ApplicationInstanceManager.setApplicationInstanceListener(new ApplicationInstanceListener() { - public void newInstanceCreated(String message) + @Override + public void newInstanceCreated(final String message) { - if (message != null && !"".equals(message)) + ThreadUtils.runInGUIThread(() -> { - if (message.startsWith("@")) + if (message != null && !"".equals(message)) { - message = message.substring(1); - VisicutApp.this.mainView.loadFile(new File(message), false); - } - else - { - VisicutApp.this.mainView.loadFile(new File(message), true); + if (message.startsWith("@")) + { + VisicutApp.this.mainView.loadFile(new File(message.substring(1)), false); + } + else + { + VisicutApp.this.mainView.loadFile(new File(message), true); + } } - } - VisicutApp.this.mainView.requestFocus(); + VisicutApp.this.mainView.requestFocus(); + }); } }); }