1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-26 20:54:22 +01:00

Kill active programmer if still alive after closing last IDE window

Fixes https://github.com/arduino/Arduino/issues/7498
This commit is contained in:
Martino Facchin 2018-11-08 18:08:58 +01:00
parent e1a5be7354
commit b71a4969af
2 changed files with 10 additions and 1 deletions

View File

@ -26,6 +26,7 @@ import cc.arduino.Compiler;
import cc.arduino.Constants;
import cc.arduino.UpdatableBoardsLibsFakeURLsHandler;
import cc.arduino.UploaderUtils;
import cc.arduino.packages.Uploader;
import cc.arduino.contributions.*;
import cc.arduino.contributions.libraries.*;
import cc.arduino.contributions.libraries.ui.LibraryManagerUI;
@ -961,6 +962,14 @@ public class Base {
// ignore
}
// kill uploader (if still alive)
UploaderUtils uploaderInstance = new UploaderUtils();
Uploader uploader = uploaderInstance.getUploaderByPreferences(false);
if (uploader != null && uploader.programmerPid != null && uploader.programmerPid.isAlive()) {
// kill the stuck programmer
uploader.programmerPid.destroyForcibly();
}
if (handleQuitEach()) {
// Save out the current prefs state
PreferencesData.save();

View File

@ -106,7 +106,7 @@ public abstract class Uploader implements MessageConsumer {
}
// static field for last executed programmer process ID
static protected Process programmerPid;
static public Process programmerPid;
protected boolean executeUploadCommand(Collection<String> command) throws Exception {
return executeUploadCommand(command.toArray(new String[command.size()]));