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.
This commit is contained in:
Thorsten Ball
2023-11-25 20:05:26 +01:00
committed by Mitchell Hashimoto
parent ba65b61fa9
commit e2a58b340c

View File

@ -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).