gtk/CommandPalette: prevent leaks on initialization

* Deallocate the builder after use
* Don't hold a reference to `Command` after appending to `GListStore`
pull/7541/head
Leorize 2025-06-07 11:57:26 -05:00
parent 1c7623db81
commit ea0766e62b
No known key found for this signature in database
GPG Key ID: F27DAB17D7AD45CE
1 changed files with 4 additions and 1 deletions

View File

@ -43,6 +43,7 @@ pub fn init(self: *CommandPalette, window: *Window) !void {
_ = Command.getGObjectType();
var builder = Builder.init("command-palette", 1, 5);
defer builder.deinit();
self.* = .{
.window = window,
@ -120,7 +121,9 @@ pub fn updateConfig(self: *CommandPalette, config: *const configpkg.Config) !voi
command,
config.keybind.set,
);
self.source.append(cmd.as(gobject.Object));
const cmd_ref = cmd.as(gobject.Object);
self.source.append(cmd_ref);
cmd_ref.unref();
}
}