From 793c19e1870571397a43dab0f2cf0508066dfeea Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 23 Feb 2023 12:01:21 -0800 Subject: [PATCH] gtk: proper surface cleanup --- src/apprt/gtk.zig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/apprt/gtk.zig b/src/apprt/gtk.zig index 503368d16..572d64fbc 100644 --- a/src/apprt/gtk.zig +++ b/src/apprt/gtk.zig @@ -292,6 +292,7 @@ pub const Surface = struct { /// "destroy" signal for surface fn gtkDestroy(v: *c.GtkWidget, ud: ?*anyopaque) callconv(.C) void { _ = v; + log.debug("gl destroy", .{}); const self = userdataSelf(ud.?); const alloc = self.app.core_app.alloc; @@ -304,7 +305,14 @@ pub const Surface = struct { } pub fn deinit(self: *Surface) void { - _ = self; + // We don't allocate anything if we aren't realized. + if (!self.realized) return; + + // Remove ourselves from the list of known surfaces in the app. + self.app.core_app.deleteSurface(self); + + // Clean up our core surface so that all the rendering and IO stop. + self.core_surface.deinit(); } pub fn setShouldClose(self: *Surface) void {