From 4a4577cf8a61bd7aa2e4fe89d61fd0b86a781dae Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 6 Aug 2025 13:57:14 -0700 Subject: [PATCH] apprt/gtk-ng: address some TODOs --- src/apprt/gtk-ng/class/tab.zig | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/apprt/gtk-ng/class/tab.zig b/src/apprt/gtk-ng/class/tab.zig index 034dd25f6..c60b01bfa 100644 --- a/src/apprt/gtk-ng/class/tab.zig +++ b/src/apprt/gtk-ng/class/tab.zig @@ -172,19 +172,23 @@ pub const Tab = extern struct { .{}, ); - // We need to do this so that the title initializes properly, - // I think because its a dynamic getter. - self.as(gobject.Object).notifyByPspec(properties.@"active-surface".impl.param_spec); - - // Setup our initial split tree. - // TODO: Probably make this a property + // A tab always starts with a single surface. const surface: *Surface = .new(); defer surface.unref(); _ = surface.refSink(); const alloc = Application.default().allocator(); - var tree = Surface.Tree.init(alloc, surface) catch unreachable; - defer tree.deinit(); - priv.split_tree.setTree(&tree); + if (Surface.Tree.init(alloc, surface)) |tree| { + priv.split_tree.setTree(&tree); + + // Hacky because we need a non-const result. + var mut = tree; + mut.deinit(); + } else |_| { + // TODO: We should make our "no surfaces" state more aesthetically + // pleasing and show something like an "Oops, something went wrong" + // message. For now, this is incredibly unlikely. + @panic("oom"); + } } fn connectSurfaceHandlers(