diff --git a/src/apprt/gtk/class/global_shortcuts.zig b/src/apprt/gtk/class/global_shortcuts.zig index cf0f31a6e..28987c259 100644 --- a/src/apprt/gtk/class/global_shortcuts.zig +++ b/src/apprt/gtk/class/global_shortcuts.zig @@ -108,34 +108,35 @@ pub const GlobalShortcuts = extern struct { fn close(self: *Self) void { const priv = self.private(); - const dbus = priv.dbus_connection orelse return; - if (priv.response_subscription != 0) { - dbus.signalUnsubscribe(priv.response_subscription); - priv.response_subscription = 0; - } + if (priv.dbus_connection) |dbus| { + if (priv.response_subscription != 0) { + dbus.signalUnsubscribe(priv.response_subscription); + priv.response_subscription = 0; + } - if (priv.activate_subscription != 0) { - dbus.signalUnsubscribe(priv.activate_subscription); - priv.activate_subscription = 0; - } + if (priv.activate_subscription != 0) { + dbus.signalUnsubscribe(priv.activate_subscription); + priv.activate_subscription = 0; + } - if (priv.handle) |handle| { - // Close existing session - dbus.call( - "org.freedesktop.portal.Desktop", - handle, - "org.freedesktop.portal.Session", - "Close", - null, - null, - .{}, - -1, - null, - null, - null, - ); - priv.handle = null; + if (priv.handle) |handle| { + // Close existing session + dbus.call( + "org.freedesktop.portal.Desktop", + handle, + "org.freedesktop.portal.Session", + "Close", + null, + null, + .{}, + -1, + null, + null, + null, + ); + priv.handle = null; + } } if (priv.arena) |*arena| { @@ -151,7 +152,8 @@ pub const GlobalShortcuts = extern struct { const priv = self.private(); - // We need configuration to proceed. + // We need a dbus connection and configuration to proceed. + if (priv.dbus_connection == null) return; const config = if (priv.config) |v| v.get() else return; // Setup our new arena that we'll use for memory allocations.