Skip to content

Commit 62c513c

Browse files
sonnyplw64
andauthored
Destroy toplevel objects (#176)
Co-authored-by: Lorenz Wildberg <lorenz@wild-fisch.de>
1 parent 8123dd5 commit 62c513c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Previewer/Internal.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ export default function Internal({
157157
object_root[prop_name] = new_value;
158158
}
159159
}
160+
161+
// Toplevel windows returned by these functions will stay around
162+
// until the user explicitly destroys them with gtk_window_destroy().
163+
// https://docs.gtk.org/gtk4/class.Builder.html
164+
if (object_preview instanceof Gtk.Window) {
165+
object_preview.destroy();
166+
}
160167
}
161168

162169
if (!object_root.name) {

src/Previewer/previewer.vala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace Workbench {
4242
var target = this.builder.get_object (target_id) as Gtk.Widget;
4343
if (target == null) {
4444
stderr.printf (@"Widget with target_id='$target_id' could not be found.\n");
45-
return;
45+
return;
4646
}
4747

4848
if (original_id != "") {
@@ -75,6 +75,13 @@ namespace Workbench {
7575
((Gtk.Window) target).child = null;
7676
this.window.child = child;
7777
}
78+
79+
// Toplevel windows returned by these functions will stay around
80+
// until the user explicitly destroys them with gtk_window_destroy().
81+
// https://docs.gtk.org/gtk4/class.Builder.html
82+
if (target is Gtk.Window) {
83+
((Gtk.Window) target).destroy();
84+
}
7885
}
7986

8087
public void update_css (string content) {

0 commit comments

Comments
 (0)