From 3b419a2ba21bb5a359c18e966c0847f2bdb63daa Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 26 Sep 2024 14:40:24 -0700 Subject: [PATCH] apprt/gtk: handle zero value notification pointers --- src/apprt/gtk/App.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/apprt/gtk/App.zig b/src/apprt/gtk/App.zig index e5a51d66d..1d97731fa 100644 --- a/src/apprt/gtk/App.zig +++ b/src/apprt/gtk/App.zig @@ -1098,8 +1098,12 @@ fn gtkActionPresentSurface( return; } - // Convert that u64 to pointer to a core surface. - const surface: *CoreSurface = @ptrFromInt(c.g_variant_get_uint64(parameter)); + // Convert that u64 to pointer to a core surface. A value of zero + // means that there was no target surface for the notification so + // we dont' focus any surface. + const ptr_int: u64 = c.g_variant_get_uint64(parameter); + if (ptr_int == 0) return; + const surface: *CoreSurface = @ptrFromInt(ptr_int); // Send a message through the core app mailbox rather than presenting the // surface directly so that it can validate that the surface pointer is