gtk: move surface destroy through deref

This commit is contained in:
Thorsten Ball
2023-11-25 16:21:42 +01:00
committed by Mitchell Hashimoto
parent 236e57a1f4
commit 3fef4fce56
2 changed files with 4 additions and 7 deletions

View File

@ -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. // GL area be moved around i.e. between a split, a tab, etc.
// without having to be really careful about ordering to // without having to be really careful about ordering to
// prevent a destroy. // 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)); _ = c.g_object_ref_sink(@ptrCast(gl_area));
errdefer c.g_object_unref(@ptrCast(gl_area)); errdefer c.g_object_unref(@ptrCast(gl_area));
@ -375,11 +377,6 @@ fn realize(self: *Surface) !void {
self.realized = true; self.realized = true;
} }
pub fn destroy(self: *Surface, alloc: Allocator) void {
self.deinit();
alloc.destroy(self);
}
pub fn deinit(self: *Surface) void { pub fn deinit(self: *Surface) void {
// We don't allocate anything if we aren't realized. // We don't allocate anything if we aren't realized.
if (!self.realized) return; if (!self.realized) return;

View File

@ -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, .{ var surface = try Surface.create(window.app.core_app.alloc, window.app, .{
.parent2 = parent_, .parent2 = parent_,
}); });
errdefer surface.destroy(window.app.core_app.alloc); errdefer surface.unref();
surface.setContainer(.{ .tab_ = self }); surface.setContainer(.{ .tab_ = self });
self.elem = .{ .surface = surface }; self.elem = .{ .surface = surface };