gtk: fix closing of surfaces by releasing the ref to gl_area

This commit is contained in:
Thorsten Ball
2023-11-20 07:04:14 +01:00
committed by Mitchell Hashimoto
parent 956fcf7349
commit ecbe910714
2 changed files with 8 additions and 1 deletions

View File

@ -387,6 +387,12 @@ pub fn deinit(self: *Surface) void {
if (self.cursor) |cursor| c.g_object_unref(cursor); if (self.cursor) |cursor| c.g_object_unref(cursor);
} }
// shutdown removes the long-held reference to the gl_area and kicks off the
// deinit/destroy process for this surface.
pub fn shutdown(self: *Surface) void {
c.g_object_unref(self.gl_area);
}
// TODO: move this // TODO: move this
/// Change the container for the surface to `container`. /// Change the container for the surface to `container`.
pub fn setContainer(self: *Surface, container: Container) void { pub fn setContainer(self: *Surface, container: Container) void {

View File

@ -151,7 +151,8 @@ pub fn init(self: *Tab, window: *Window, parent_: ?*CoreSurface) !void {
/// Deinits tab by deiniting child if child is Paned. /// Deinits tab by deiniting child if child is Paned.
pub fn deinit(self: *Tab) void { pub fn deinit(self: *Tab) void {
switch (self.child) { switch (self.child) {
.none, .surface => return, .none => return,
.surface => |s| s.shutdown(),
.paned => |paned| { .paned => |paned| {
paned.deinit(self.window.app.core_app.alloc); paned.deinit(self.window.app.core_app.alloc);
self.window.app.core_app.alloc.destroy(paned); self.window.app.core_app.alloc.destroy(paned);