mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-03 12:28:13 +08:00
gtk: fix missing dbus connection causing crash
Changes GlobalShortcuts.refresh to do nothing when there is no dbus connection and GlobalShortcuts.close to always clean up arena memory.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user