26
26
import cc .arduino .Constants ;
27
27
import cc .arduino .UpdatableBoardsLibsFakeURLsHandler ;
28
28
import cc .arduino .UploaderUtils ;
29
+ import cc .arduino .packages .Uploader ;
29
30
import cc .arduino .contributions .*;
30
31
import cc .arduino .contributions .libraries .*;
31
32
import cc .arduino .contributions .libraries .ui .LibraryManagerUI ;
@@ -925,45 +926,20 @@ public void actionPerformed(ActionEvent actionEvent) {
925
926
*/
926
927
public boolean handleClose (Editor editor ) {
927
928
// Check if modified
928
- // boolean immediate = editors.size() == 1;
929
929
if (!editor .checkModified ()) {
930
930
return false ;
931
931
}
932
932
933
933
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 ();
945
934
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 ();
951
936
952
937
} else {
953
938
// More than one editor window open,
954
939
// proceed with closing the current window.
955
940
editor .setVisible (false );
956
941
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
+
967
943
editors .remove (editor );
968
944
}
969
945
return true ;
@@ -986,6 +962,14 @@ public boolean handleQuit() {
986
962
// ignore
987
963
}
988
964
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
+
989
973
if (handleQuitEach ()) {
990
974
// Save out the current prefs state
991
975
PreferencesData .save ();
0 commit comments