From d8e8619f6ee6f79607a500f28c642bd32b05014e Mon Sep 17 00:00:00 2001 From: Jakub Valtar Date: Mon, 23 Jan 2017 03:09:51 +0100 Subject: [PATCH] Fix restarting sketch in Debug mode when Run is pressed Disconnect event of the old VM would arrive after the new VM was created, closing it instantly and leaving user without a running sketch. --- java/src/processing/mode/java/Debugger.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/java/src/processing/mode/java/Debugger.java b/java/src/processing/mode/java/Debugger.java index 131fe5faa..c4be8c3a7 100644 --- a/java/src/processing/mode/java/Debugger.java +++ b/java/src/processing/mode/java/Debugger.java @@ -533,6 +533,12 @@ public class Debugger { * @param es Incoming set of events from VM */ public synchronized void vmEvent(EventSet es) { + VirtualMachine vm = vm(); + if (vm != null && vm != es.virtualMachine()) { + // This is no longer VM we are interested in, + // we already cleaned up and run different VM now. + return; + } for (Event e : es) { log("*** VM Event: " + e); if (e instanceof VMStartEvent) {