apprt/gtk-ng: clear weakrefs on dispose

pull/8212/head
Mitchell Hashimoto 2025-08-14 09:29:00 -07:00
parent 76d84ff35c
commit 7548dcfe63
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
1 changed files with 7 additions and 0 deletions

View File

@ -96,6 +96,13 @@ pub const InspectorWindow = extern struct {
}
fn dispose(self: *Self) callconv(.c) void {
// You MUST clear all weak refs in dispose, otherwise it causes
// memory corruption on dispose on the TARGET (weak referenced)
// object. The only way we caught this is via Valgrind. Its not a leak,
// its an invalid memory read. In practice, I found this sometimes
// caused hanging!
self.setSurface(null);
gtk.Widget.disposeTemplate(
self.as(gtk.Widget),
getGObjectType(),