Widget assertion failed on action emit

gtk_widget_is_ancestor: assertion 'GTK_IS_WIDGET (widget)' failed

it works on enter key press

widget.connect_activate(|entry| {
    entry
        .activate_action("win.tab_page_reload", None)
        .expect("Action `win.tab_page_reload` not found")
});

but assertion error when emitting signal after window init

parent.entry.emit_activate();

I still can get entry text in both cases, it means that entry address accessible, but assertion alert… strange.

I’m following this guide, but don’t see any macro / conversions there and entry from the argument should be valid widget anyway:
https://gtk-rs.org/gtk4-rs/stable/latest/book/actions.html

Maybe the library bug?

Hi,

All widgets may not have been fully initialized if you call emit_activate() too early at init.

You may want to emit asynchronously, e.g. by passing emit_activate to GLib.idle_add_once (I don’t know the rust equivalent, sorry).

1 Like