From e2a58b340c5691a5dbdc1857b0a13c77555c4660 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Sat, 25 Nov 2023 20:05:26 +0100 Subject: [PATCH] gtk: (temp) fix splitting top_left side in split Before this change, it would crash when you had the following surfaces split1 / \ / \ surf1 \ split2 / \ surf2 surf3 and you'd want to split `surf1` again. Splitting `surf2` or `surf3` would be fine, but surf1 would break things. --- src/apprt/gtk/Split.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/apprt/gtk/Split.zig b/src/apprt/gtk/Split.zig index 5ab4c3e8c..db9fc58ab 100644 --- a/src/apprt/gtk/Split.zig +++ b/src/apprt/gtk/Split.zig @@ -159,6 +159,19 @@ pub fn grabFocus(self: *Split) void { /// This should be called anytime the top/left or bottom/right /// element is changed. fn updateChildren(self: *const Split) void { + // TODO: Not sure we should keep this. + // + // We keep references to both widgets, because only Surface widgets have + // long-held references but GtkPaned will also get destroyed if we don't + // keep a reference here before removing. + const top_left_object: *c.GObject = @ptrCast(self.top_left.widget()); + _ = c.g_object_ref(top_left_object); + defer c.g_object_unref(top_left_object); + + const bottom_right_object: *c.GObject = @ptrCast(self.bottom_right.widget()); + _ = c.g_object_ref(bottom_right_object); + defer c.g_object_unref(bottom_right_object); + // We have to set both to null. If we overwrite the pane with // the same value, then GTK bugs out (the GL area unrealizes // and never rerealizes).