gtk-ng: don't add extra refs when activating a command in the palette

This commit is contained in:
Jeffrey C. Ollie
2025-08-08 13:49:13 -05:00
committed by Mitchell Hashimoto
parent 2a5b7aab86
commit 8af1230228

View File

@@ -217,24 +217,19 @@ pub const CommandPalette = extern struct {
/// Helper function to send a signal containing the action that should be
/// performed.
fn activated(self: *CommandPalette, pos: c_uint) void {
// add a reference to keep ourselves around until we're done
_ = self.ref();
defer self.unref();
const priv = self.private();
// Use priv.model and not priv.source here to use the list of *visible* results
const object_ = priv.model.as(gio.ListModel).getObject(pos);
defer if (object_) |object| object.unref();
// Close before running the action in order to avoid being replaced by
// another dialog (such as the change title dialog). If that occurs then
// the command palette dialog won't be counted as having closed properly
// and cannot receive focus when reopened.
_ = priv.dialog.close();
// Use priv.model and not priv.source here to use the list of *visible* results
const object = priv.model.as(gio.ListModel).getObject(pos) orelse return;
defer object.unref();
const cmd = gobject.ext.cast(Command, object) orelse return;
const cmd = gobject.ext.cast(Command, object_ orelse return) orelse return;
const action = cmd.getAction() orelse return;
// Signal that an an action has been selected. Signals are synchronous