From 3fef4fce5682975230f39a678e7858c33ba2a66e Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Sat, 25 Nov 2023 16:21:42 +0100 Subject: [PATCH] gtk: move surface destroy through deref --- src/apprt/gtk/Surface.zig | 9 +++------ src/apprt/gtk/Tab.zig | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/apprt/gtk/Surface.zig b/src/apprt/gtk/Surface.zig index c1eefc3c6..b0b317199 100644 --- a/src/apprt/gtk/Surface.zig +++ b/src/apprt/gtk/Surface.zig @@ -223,7 +223,9 @@ pub fn init(self: *Surface, app: *App, opts: Options) !void { // GL area be moved around i.e. between a split, a tab, etc. // without having to be really careful about ordering to // prevent a destroy. - // TODO: unref in deinit + // + // This is unref'd in the unref() method that's called by the + // self.container through Elem.deinit. _ = c.g_object_ref_sink(@ptrCast(gl_area)); errdefer c.g_object_unref(@ptrCast(gl_area)); @@ -375,11 +377,6 @@ fn realize(self: *Surface) !void { self.realized = true; } -pub fn destroy(self: *Surface, alloc: Allocator) void { - self.deinit(); - alloc.destroy(self); -} - pub fn deinit(self: *Surface) void { // We don't allocate anything if we aren't realized. if (!self.realized) return; diff --git a/src/apprt/gtk/Tab.zig b/src/apprt/gtk/Tab.zig index 867956d0e..4b7ef5ccb 100644 --- a/src/apprt/gtk/Tab.zig +++ b/src/apprt/gtk/Tab.zig @@ -96,7 +96,7 @@ pub fn init(self: *Tab, window: *Window, parent_: ?*CoreSurface) !void { var surface = try Surface.create(window.app.core_app.alloc, window.app, .{ .parent2 = parent_, }); - errdefer surface.destroy(window.app.core_app.alloc); + errdefer surface.unref(); surface.setContainer(.{ .tab_ = self }); self.elem = .{ .surface = surface };