fix reference count for action group arguments

This commit is contained in:
yggverse 2024-11-10 12:05:36 +02:00
parent 6f7a21705e
commit 86fba1dc69
2 changed files with 18 additions and 6 deletions

View File

@ -37,10 +37,22 @@ impl Browser {
let widget = Rc::new(Widget::new(
window.gobject(),
&[
// Connect action groups
(action.id(), action.gobject()),
(window.action().id(), window.action().gobject()),
(window.tab().action().id(), window.tab().action().gobject()),
// Connect action groups (to apply accels)
(
// Browser
action.id(),
action.gobject().clone(),
),
(
// Window
window.action().id(),
window.action().gobject().clone(),
),
(
// Tab
window.tab().action().id(),
window.tab().action().gobject().clone(),
),
],
));

View File

@ -22,7 +22,7 @@ impl Widget {
// Construct
pub fn new(
content: &impl IsA<gtk::Widget>,
action_groups: &[(&GString, &SimpleActionGroup)],
action_groups: &[(&GString, SimpleActionGroup)],
) -> Self {
// Init GTK
let gobject = ApplicationWindow::builder()
@ -34,7 +34,7 @@ impl Widget {
// Register actions
for (name, group) in action_groups {
gobject.insert_action_group(name, Some(group.clone()));
gobject.insert_action_group(name, Some(group));
}
// Return new struct