Skip to content

Commit

Permalink
Fix non-GUI-thread warning
Browse files Browse the repository at this point in the history
Fixes t-oster#696

"java.lang.Exception: Warning: A GUI function was called from the non-GUI thread Thread-0. This may cause sporadic errors and should therefore be fixed."
  • Loading branch information
mgmax committed Dec 15, 2023
1 parent 886ab0b commit 4df1395
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/main/java/de/thomas_oster/visicut/gui/VisicutApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
});
}
Expand Down

0 comments on commit 4df1395

Please sign in to comment.