Skip to content

Commit af392ae

Browse files
authored
Merge pull request #4842 from JakubValtar/fix-sketchbook-update
Rebuild sketchbook window when needed
2 parents 2fb23f6 + 7b8f307 commit af392ae

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

app/src/processing/app/Mode.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ public void rebuildExamplesFrame() {
656656
if (visible) {
657657
bounds = examplesFrame.getBounds();
658658
examplesFrame.setVisible(false);
659+
examplesFrame.dispose();
659660
}
660661
examplesFrame = null;
661662
if (visible) {
@@ -691,11 +692,19 @@ public DefaultMutableTreeNode buildSketchbookTree() {
691692

692693
/** Sketchbook has changed, update it on next viewing. */
693694
public void rebuildSketchbookFrame() {
694-
boolean wasVisible =
695-
(sketchbookFrame == null) ? false : sketchbookFrame.isVisible();
696-
sketchbookFrame = null; // Force a rebuild
697-
if (wasVisible) {
698-
showSketchbookFrame();
695+
if (sketchbookFrame != null) {
696+
boolean visible = sketchbookFrame.isVisible();
697+
Rectangle bounds = null;
698+
if (visible) {
699+
bounds = sketchbookFrame.getBounds();
700+
sketchbookFrame.setVisible(false);
701+
sketchbookFrame.dispose();
702+
}
703+
sketchbookFrame = null;
704+
if (visible) {
705+
showSketchbookFrame();
706+
sketchbookFrame.setBounds(bounds);
707+
}
699708
}
700709
}
701710

app/src/processing/app/Sketch.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,10 @@ public void handleDeleteCode() {
657657
// get the changes into the sketchbook menu
658658
//sketchbook.rebuildMenus();
659659

660-
// make a new sketch, and i think this will rebuild the sketch menu
660+
// make a new sketch and rebuild the sketch menu
661661
//editor.handleNewUnchecked();
662662
//editor.handleClose2();
663+
editor.getBase().rebuildSketchbookMenus();
663664
editor.getBase().handleClose(editor, false);
664665

665666
} else {

0 commit comments

Comments
 (0)