GNOME Bugzilla – Bug 758813
Gio::ActionMap::lookup_action() causes crash
Last modified: 2015-12-03 15:48:42 UTC
If I call lookup_action() in an Gtk::ApplicationWindow, it crashes. I pass in a valid action name, that was previously added to map. If I call g_action_map_lookup_action() directly, it works and returns a not-NULL GAction.
I don't see anything obviously wrong in the generated code, though there is a lookup_action_vfunc() which might have strange side-effects. Do you have a backtrace? A simple test case would be nice too.
Spent more time investigating, so the findings are: - failure happens when searching for actually added action - it doesn't crash on a very simple application, but causes failures and prevents window from opening in the attached sample - I get crash in Gnote I'm working on. Don't know why exactly that happens, but it looks to be when making C++ wrapper for C object. I'll post a stack trace.
Created attachment 316555 [details] Test case Command line output: [aurimas@localhost gtkmmt]$ ./gtkmmt (gtkmmt:11098): glibmm-WARNING **: This object, of type gtkmm__GtkApplicationWindow, already has a wrapper. You should use wrap() instead of a constructor. (gtkmmt:11098): GLib-GObject-CRITICAL **: g_object_get_qdata: assertion 'G_IS_OBJECT (object)' failed (gtkmmt:11098): GLib-GObject-CRITICAL **: g_object_get_qdata: assertion 'G_IS_OBJECT (object)' failed
Stacktrace from crash I get in Gnote: (gdb) bt
+ Trace 235776
The test case, together with gdb, shows that the error is in auto win = new Gtk::ApplicationWindow(App::s_app); Something is wrong with the ApplicationWindow constructor that takes a const Glib::RefPtr<Gtk::Application>&. A simple workaround is to replace that line with auto win = new Gtk::ApplicationWindow(); App::s_app->add_window(*win);
(In reply to Kjell Ahlstedt from comment #5) > The test case, together with gdb, shows that the error is in > > auto win = new Gtk::ApplicationWindow(App::s_app); > > Something is wrong with the ApplicationWindow constructor that takes a > const Glib::RefPtr<Gtk::Application>&. Yes, that too. But it's not what this bug is about. Unless that makes lookup_action() work? I remember that warning from constructor since it appeared, btw.
You're right. Your test case triggers two independent bugs, one in the Gtk::ApplicationWindow constructor and one in Gio::ActionMap:: lookup_action_vfunc(). I have fixed the bug in ActioMap. https://git.gnome.org/browse/glibmm/commit/?id=10bf57e3a014351f65a8fe350269ec3df0293fc2 I keep this bug open until the bug in ApplicationWindow has also been fixed.
Created attachment 316724 [details] Test case 2 A modified test case. This test case uses a window derived from Gtk::ApplicationWindow instead of a plain Gtk::ApplicationWindow. Then it can clearly show the bug in Gio::ActionMap::lookup_action_vfunc() even if the bug in the Gtk::ApplicationWindow constructor has been fixed.
Now the bug the Gtk::ApplicationWindow constructor has been fixed. I've hand-coded the failing constructor and added a comment explaining why the gmmproc-generated version can't be used. https://git.gnome.org/browse/gtkmm/commit/?id=c4500fe8c1f2d5d98e04aaabcdafa1e5b794e548