From 7d277b359cc47e2e00547b77051b009bf5c8b8bf Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 17 Dec 2015 16:18:02 +0100 Subject: [PATCH] Remove Editor.stopHandler This handler was only always assigned the DefaultStopHandler, which did nothing. It was called in a few places, but since it never does anything, better remove it. For properly supporting stopping of external processes, some better architecture should be added instead. --- app/src/processing/app/Base.java | 11 ----------- app/src/processing/app/Editor.java | 26 -------------------------- 2 files changed, 37 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index e8d4bf155..0b403f427 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -762,8 +762,6 @@ public class Base { if (!activeEditor.checkModified()) { return; // sketch was modified, and user canceled } - // Close the running window, avoid window boogers with multiple sketches - activeEditor.internalCloseRunner(); // Actually replace things handleNewReplaceImpl(); @@ -788,8 +786,6 @@ public class Base { if (!activeEditor.checkModified()) { return; // sketch was modified, and user canceled } - // Close the running window, avoid window boogers with multiple sketches - activeEditor.internalCloseRunner(); boolean loaded = activeEditor.handleOpenInternal(file); if (!loaded) { @@ -947,9 +943,6 @@ public class Base { return false; } - // Close the running window, avoid window boogers with multiple sketches - editor.internalCloseRunner(); - if (editors.size() == 1) { storeSketches(); @@ -1005,10 +998,6 @@ public class Base { } if (handleQuitEach()) { - // make sure running sketches close before quitting - for (Editor editor : editors) { - editor.internalCloseRunner(); - } // Save out the current prefs state PreferencesData.save(); diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 1de5a3b81..6291f0187 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -194,7 +194,6 @@ public class Editor extends JFrame implements RunnerListener { Runnable presentHandler; private Runnable runAndSaveHandler; private Runnable presentAndSaveHandler; - private Runnable stopHandler; Runnable exportHandler; private Runnable exportAppHandler; private Runnable timeoutUploadHandler; @@ -1558,7 +1557,6 @@ public class Editor extends JFrame implements RunnerListener { presentHandler = new BuildHandler(true); runAndSaveHandler = new BuildHandler(false, true); presentAndSaveHandler = new BuildHandler(true, true); - stopHandler = new DefaultStopHandler(); exportHandler = new DefaultExportHandler(); exportAppHandler = new DefaultExportAppHandler(); timeoutUploadHandler = new TimeoutUploadHandler(); @@ -1718,7 +1716,6 @@ public class Editor extends JFrame implements RunnerListener { } private void handleRun(final boolean verbose, Predicate shouldSavePredicate, Runnable verboseHandler, Runnable nonVerboseHandler) { - internalCloseRunner(); if (shouldSavePredicate.test(sketchController)) { handleSave(true); } @@ -1787,13 +1784,6 @@ public class Editor extends JFrame implements RunnerListener { getCurrentTab().getTextArea().setCaretPosition(getCurrentTab().getTextArea().getLineStartOffset(line)); } - private class DefaultStopHandler implements Runnable { - public void run() { - // TODO - // DAM: we should try to kill the compilation or upload process here. - } - } - /** * Implements Sketch → Stop, or pressing Stop on the toolbar. @@ -1801,8 +1791,6 @@ public class Editor extends JFrame implements RunnerListener { private void handleStop() { // called by menu or buttons // toolbar.activate(EditorToolbar.STOP); - internalCloseRunner(); - toolbar.deactivateRun(); // toolbar.deactivate(EditorToolbar.STOP); @@ -1810,19 +1798,6 @@ public class Editor extends JFrame implements RunnerListener { toFront(); } - - /** - * Handle internal shutdown of the runner. - */ - public void internalCloseRunner() { - - if (stopHandler != null) - try { - stopHandler.run(); - } catch (Exception e) { } - } - - /** * Check if the sketch is modified and ask user to save changes. * @return false if canceling the close/quit operation @@ -1904,7 +1879,6 @@ public class Editor extends JFrame implements RunnerListener { */ protected void handleOpenUnchecked(File file, int codeIndex, int selStart, int selStop, int scrollPos) { - internalCloseRunner(); handleOpenInternal(file); // Replacing a document that may be untitled. If this is an actual // untitled document, then editor.untitled will be set by Base.