2626import cc .arduino .Constants ;
2727import cc .arduino .UpdatableBoardsLibsFakeURLsHandler ;
2828import cc .arduino .UploaderUtils ;
29+ import cc .arduino .packages .Uploader ;
2930import cc .arduino .contributions .*;
3031import cc .arduino .contributions .libraries .*;
3132import 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 ();
0 commit comments