Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c1d9c58

Browse files
Merge pull request #8184 from facchinm/kill_programmer_at_exit
Kill active programmer if still alive after closing last IDE window
2 parents 8309fb2 + b71a496 commit c1d9c58

File tree

2 files changed

+12
-28
lines changed

2 files changed

+12
-28
lines changed

‎app/src/processing/app/Base.java‎

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import cc.arduino.Constants;
2727
import cc.arduino.UpdatableBoardsLibsFakeURLsHandler;
2828
import cc.arduino.UploaderUtils;
29+
import cc.arduino.packages.Uploader;
2930
import cc.arduino.contributions.*;
3031
import cc.arduino.contributions.libraries.*;
3132
import cc.arduino.contributions.libraries.ui.LibraryManagerUI;
@@ -925,45 +926,20 @@ public void actionPerformed(ActionEvent actionEvent) {
925926
*/
926927
public boolean handleClose(Editor editor) {
927928
// Check if modified
928-
// boolean immediate = editors.size() == 1;
929929
if (!editor.checkModified()) {
930930
return false;
931931
}
932932

933933
if (editors.size() == 1) {
934-
storeScreenDimensions();
935-
storeSketches();
936-
937-
// This will store the sketch count as zero
938-
editors.remove(editor);
939-
try {
940-
Editor.serialMonitor.close();
941-
} catch (Exception e) {
942-
//ignore
943-
}
944-
rebuildRecentSketchesMenuItems();
945934

946-
// Save out the current prefs state
947-
PreferencesData.save();
948-
949-
// Since this wasn't an actual Quit event, call System.exit()
950-
System.exit(0);
935+
handleQuit();
951936

952937
} else {
953938
// More than one editor window open,
954939
// proceed with closing the current window.
955940
editor.setVisible(false);
956941
editor.dispose();
957-
// for (int i = 0; i < editorCount; i++) {
958-
// if (editor == editors[i]) {
959-
// for (int j = i; j < editorCount-1; j++) {
960-
// editors[j] = editors[j+1];
961-
// }
962-
// editorCount--;
963-
// // Set to null so that garbage collection occurs
964-
// editors[editorCount] = null;
965-
// }
966-
// }
942+
967943
editors.remove(editor);
968944
}
969945
return true;
@@ -986,6 +962,14 @@ public boolean handleQuit() {
986962
// ignore
987963
}
988964

965+
// kill uploader (if still alive)
966+
UploaderUtils uploaderInstance = new UploaderUtils();
967+
Uploader uploader = uploaderInstance.getUploaderByPreferences(false);
968+
if (uploader != null && uploader.programmerPid != null && uploader.programmerPid.isAlive()) {
969+
// kill the stuck programmer
970+
uploader.programmerPid.destroyForcibly();
971+
}
972+
989973
if (handleQuitEach()) {
990974
// Save out the current prefs state
991975
PreferencesData.save();

‎arduino-core/src/cc/arduino/packages/Uploader.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public String getAuthorizationKey() {
106106
}
107107

108108
// static field for last executed programmer process ID
109-
static protected Process programmerPid;
109+
static public Process programmerPid;
110110

111111
protected boolean executeUploadCommand(Collection<String> command) throws Exception {
112112
return executeUploadCommand(command.toArray(new String[command.size()]));

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /