GNOME Bugzilla – Bug 589267
Crash when Gtk::Builder::get_widget() doesn't find the specified widget
Last modified: 2009-07-23 17:18:09 UTC
Steps to reproduce: If I use the Gtk::Builder::get_widget() function to get a widget that doesn't exist in the .ui file, I get the following: (example:15351): gtkmm-CRITICAL **: gtkmm: object `DialogBasic_' not found in GtkBuilder file. Segmentation fault Note that this happens even if I try to catch the exceptions. The following example (modified from gtkmm-documentation-2.16.0/examples/book/builder/basic/main.cc) demonstrates the issue. #include <gtkmm.h> #include <iostream> int main (int argc, char **argv) { Gtk::Main kit(argc, argv); //Load the GtkBuilder file and instantiate its widgets: Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create(); try { refBuilder->add_from_file("basic.ui"); } catch(const Glib::Error& ex) { std::cerr << "Gtk::Builder::create() error: " << ex.what() << std::endl; return 1; } Gtk::Dialog* pDialog = 0; try { // Notice the invalid name! refBuilder->get_widget("DialogBasic_DOES_NOT_EXIST", pDialog); } catch(const Glib::Error& ex) { std::cerr << "get_widget() error: " << ex.what() << std::endl; } if(pDialog) { kit.run(*pDialog); } return 0; } Stack trace:
+ Trace 216558
Other information: Tested with gtkmm 2.16.0, gtk2-2.16.4 on openSUSE 11.1 x86_64.
Forgot to add, the "basic.ui" file comes from gtkmm-documentation-2.16.0/examples/book/builder/basic/basic.ui . You can just drop the above example as main.cc in there and it will compile. Also, this is somewhat related to http://bugzilla.gnome.org/show_bug.cgi?id=548022
This should be fixed by this commit in master, which I will cherry-pick to other branches tomorrow too: 2009-07-23 Murray Cumming <murrayc@murrayc.com> Gtk::Builder: Fix a crash when the widget is not found. * gtk/src/builder.ccg: get_widget_checked(): Prevent a crash if the widget was not found by GtkBuilder. Bug #589267 (Alexander Shaduri)