@@ -1371,10 +1371,13 @@ public void actionPerformed(ActionEvent e) {
13711371 redoAction .updateRedoState ();
13721372 if (sketch != null ) {
13731373 sketch .setModified (!getText ().equals (sketch .getCurrentCode ().getSavedProgram ()));
1374+ // Go through all tabs; Replace All, Rename or Undo could have changed them
13741375 for (SketchCode sc : sketch .getCode ()) {
1375- try {
1376- sc .setModified (!sc .getDocumentText ().equals (sc .getSavedProgram ()));
1377- } catch (BadLocationException ignore ) { }
1376+ if (sc .getDocument () != null ) {
1377+ try {
1378+ sc .setModified (!sc .getDocumentText ().equals (sc .getSavedProgram ()));
1379+ } catch (BadLocationException ignore ) { }
1380+ }
13781381 }
13791382 repaintHeader ();
13801383 }
@@ -1433,10 +1436,14 @@ public void actionPerformed(ActionEvent e) {
14331436 undoAction .updateUndoState ();
14341437 if (sketch != null ) {
14351438 sketch .setModified (!getText ().equals (sketch .getCurrentCode ().getSavedProgram ()));
1439+ // Go through all tabs; Replace All, Rename or Undo could have changed them
14361440 for (SketchCode sc : sketch .getCode ()) {
1437- try {
1438- sc .setModified (!sc .getDocumentText ().equals (sc .getSavedProgram ()));
1439- } catch (BadLocationException ignore ) { }
1441+ if (sc .getDocument () != null ) {
1442+ try {
1443+ sc .setModified (!sc .getDocumentText ().equals (sc .getSavedProgram ()));
1444+ } catch (BadLocationException ignore ) {
1445+ }
1446+ }
14401447 }
14411448 repaintHeader ();
14421449 }
@@ -2717,10 +2724,14 @@ public void prepareRun() {
27172724
27182725 // make sure any edits have been stored
27192726 //current.setProgram(editor.getText());
2727+ // Go through all tabs; Replace All, Rename or Undo could have changed them
27202728 for (SketchCode sc : sketch .getCode ()) {
2721- try {
2722- sc .setProgram (sc .getDocumentText ());
2723- } catch (BadLocationException e ) { }
2729+ if (sc .getDocument () != null ) {
2730+ try {
2731+ sc .setProgram (sc .getDocumentText ());
2732+ } catch (BadLocationException e ) {
2733+ }
2734+ }
27242735 }
27252736
27262737// // if an external editor is being used, need to grab the
0 commit comments