gtk-ng: don't add extra refs when activating a command in the palette
parent
2a5b7aab86
commit
8af1230228
|
|
@ -217,24 +217,19 @@ pub const CommandPalette = extern struct {
|
||||||
/// Helper function to send a signal containing the action that should be
|
/// Helper function to send a signal containing the action that should be
|
||||||
/// performed.
|
/// performed.
|
||||||
fn activated(self: *CommandPalette, pos: c_uint) void {
|
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();
|
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
|
// Close before running the action in order to avoid being replaced by
|
||||||
// another dialog (such as the change title dialog). If that occurs then
|
// another dialog (such as the change title dialog). If that occurs then
|
||||||
// the command palette dialog won't be counted as having closed properly
|
// the command palette dialog won't be counted as having closed properly
|
||||||
// and cannot receive focus when reopened.
|
// and cannot receive focus when reopened.
|
||||||
_ = priv.dialog.close();
|
_ = priv.dialog.close();
|
||||||
|
|
||||||
// Use priv.model and not priv.source here to use the list of *visible* results
|
const cmd = gobject.ext.cast(Command, object_ orelse return) orelse return;
|
||||||
const object = priv.model.as(gio.ListModel).getObject(pos) orelse return;
|
|
||||||
defer object.unref();
|
|
||||||
|
|
||||||
const cmd = gobject.ext.cast(Command, object) orelse return;
|
|
||||||
|
|
||||||
const action = cmd.getAction() orelse return;
|
const action = cmd.getAction() orelse return;
|
||||||
|
|
||||||
// Signal that an an action has been selected. Signals are synchronous
|
// Signal that an an action has been selected. Signals are synchronous
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue