From 0a26321e9d48e2cbffeef2571512d8093a8e8393 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Fri, 10 Jan 2025 19:19:11 -0600 Subject: [PATCH] gtk: add some comments about closing the last tab invaldating self pointer --- src/apprt/gtk/notebook_adw.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/apprt/gtk/notebook_adw.zig b/src/apprt/gtk/notebook_adw.zig index b4190fbc4..89a316332 100644 --- a/src/apprt/gtk/notebook_adw.zig +++ b/src/apprt/gtk/notebook_adw.zig @@ -127,6 +127,8 @@ pub const NotebookAdw = struct { self.forcing_close = true; const n = self.nPages(); defer { + // self becomes invalid if we close the last page because we close + // the whole window if (n > 1) self.forcing_close = false; } @@ -146,6 +148,8 @@ pub const NotebookAdw = struct { c.g_object_unref(tab.box); } + // `self` will become invalid after this call because it will have + // been freed up as part of the process of closing the window. c.gtk_window_destroy(tab.window.window); } }