diff --git a/src/Previewer/Internal.js b/src/Previewer/Internal.js index 618461d19..b61397c03 100644 --- a/src/Previewer/Internal.js +++ b/src/Previewer/Internal.js @@ -157,6 +157,13 @@ export default function Internal({ object_root[prop_name] = new_value; } } + + // Toplevel windows returned by these functions will stay around + // until the user explicitly destroys them with gtk_window_destroy(). + // https://docs.gtk.org/gtk4/class.Builder.html + if (object_preview instanceof Gtk.Window) { + object_preview.destroy(); + } } if (!object_root.name) { diff --git a/src/Previewer/previewer.vala b/src/Previewer/previewer.vala index 31794c269..cd6d32264 100644 --- a/src/Previewer/previewer.vala +++ b/src/Previewer/previewer.vala @@ -42,7 +42,7 @@ namespace Workbench { var target = this.builder.get_object (target_id) as Gtk.Widget; if (target == null) { stderr.printf (@"Widget with target_id='$target_id' could not be found.\n"); - return; + return; } if (original_id != "") { @@ -75,6 +75,13 @@ namespace Workbench { ((Gtk.Window) target).child = null; this.window.child = child; } + + // Toplevel windows returned by these functions will stay around + // until the user explicitly destroys them with gtk_window_destroy(). + // https://docs.gtk.org/gtk4/class.Builder.html + if (target is Gtk.Window) { + ((Gtk.Window) target).destroy(); + } } public void update_css (string content) {