From 43f261a7aa0c9b1124a795f5c78304f86c87e368 Mon Sep 17 00:00:00 2001 From: Gal Sasson Date: Sun, 18 Oct 2015 01:11:37 -0400 Subject: [PATCH] fix swing deadlock issue: https://github.com/processing/processing/issues/3928 --- java/src/processing/mode/java/JavaMode.java | 24 +++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/java/src/processing/mode/java/JavaMode.java b/java/src/processing/mode/java/JavaMode.java index 1a2b64c95..8a09e1e73 100644 --- a/java/src/processing/mode/java/JavaMode.java +++ b/java/src/processing/mode/java/JavaMode.java @@ -35,6 +35,8 @@ import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.SwingUtilities; + import processing.app.*; import processing.app.ui.Editor; import processing.app.ui.EditorException; @@ -216,17 +218,27 @@ public class JavaMode extends Mode { // } // next lines are executed when the sketch quits if (launchInteractive) { - editor.initEditorCode(parser.allHandles, false); - editor.stopTweakMode(parser.allHandles); + // fix swing deadlock issue: https://github.com/processing/processing/issues/3928 + SwingUtilities.invokeLater(new Runnable() { + public void run() { + editor.initEditorCode(parser.allHandles, false); + editor.stopTweakMode(parser.allHandles); + } + }); } } }).start(); if (launchInteractive) { - // replace editor code with baseCode - editor.initEditorCode(parser.allHandles, false); - editor.updateInterface(parser.allHandles, parser.colorBoxes); - editor.startTweakMode(); + // fix swing deadlock issue: https://github.com/processing/processing/issues/3928 + SwingUtilities.invokeLater(new Runnable() { + public void run() { + // replace editor code with baseCode + editor.initEditorCode(parser.allHandles, false); + editor.updateInterface(parser.allHandles, parser.colorBoxes); + editor.startTweakMode(); + } + }); } return runtime; }