GNOME Bugzilla – Bug 548022
Gtk::Builder::get_widget(): Incomplete documentation about exceptions thrown
Last modified: 2010-04-07 13:41:26 UTC
Steps to reproduce: Gtk::Builder's get_widget() crashes when a widget with the specified name doesn't exist in the interface file. The most straightforward way to reproduce this is to open gtkmm's examples/book/builder/basic/main.cc and change "DialogBasic" to "DialogBasic_" on line 30. After that, the compiled program will exit with the following: (main:4706): gtkmm-CRITICAL **: gtkmm: object `DialogBasic_' not found in GtkBuilder file. Segmentation fault Btw, the documentation seems to be incorrect in which exception the Builder's functions throw. It mentions Glib::FileError and Glib::MarkupError, while the example says Glib::BuildError. Stack trace:
+ Trace 205230
Other information: gtkmm2-2.12.7, glibmm2-2.16.1, gtk2-2.12.11, glib2-2.16.5, gcc-4.2, glibc-2.6.1. OpenSUSE 10.3.
Yes. I have added that catch to the examples. But we really need to find out what GErrors these C functions throw so we can document the exceptions properly in our C++ Gtk::Builder documentation. I filed bug #560147 about that.
It seems that we have a "two issues in one bug" situation - a segfault (more important), and a documentation issue (less important). The title reflects the less important issue. Should I file one of them separately (which one)?
Doesn't it just fix the crash if you catch that exception? If there are two separate bugs then please do file two bug reports.
(In reply to comment #1) > Yes. I have added that catch to the examples. Sorry, but the master version at http://git.gnome.org/cgit/gtkmm-documentation/tree/examples/book/builder/basic/main.cc doesn't have the try/catch block around the get_widget() call. Or am I looking at the wrong version? (In reply to comment #3) > Doesn't it just fix the crash if you catch that exception? If there are two > separate bugs then please do file two bug reports. > No, it doesn't. No exception is thrown (at least in 2.16.0). I filed http://bugzilla.gnome.org/show_bug.cgi?id=589267 about that.
(In reply to comment #4) > (In reply to comment #1) > > Yes. I have added that catch to the examples. > > Sorry, but the master version at > http://git.gnome.org/cgit/gtkmm-documentation/tree/examples/book/builder/basic/main.cc > doesn't have the try/catch block around the get_widget() call. Or am I looking > at the wrong version? I added the catch around the add_to_file() call: http://git.gnome.org/cgit/gtkmm-documentation/commit/?id=500884ea10a3dfc1b18cf488b56e9fc0938b989f I don't think get_widget() throws any exception. Or are you sure that it does?
(In reply to comment #5) > I added the catch around the add_to_file() call: > http://git.gnome.org/cgit/gtkmm-documentation/commit/?id=500884ea10a3dfc1b18cf488b56e9fc0938b989f > > I don't think get_widget() throws any exception. Or are you sure that it does? > Sorry, I assumed that since it's get_widget() that causes the segfault, the try/catch would need to be around it. I'm not aware of any exceptions it may throw. My mistake. I guess this leaves us with fixing the documentation about the exact exceptions being thrown by, say, add_from_file() (I can think of at least three: Glib::FileError, Glib::MarkupError, Glib::BuildError). We will probably have to wait for gtk bug http://bugzilla.gnome.org/show_bug.cgi?id=560147 to be resolved.
Fixed with this commit: 2010-04-07 Murray Cumming <murrayc@murrayc.com> Builder: Complete the exceptions thrown documentation. * gtk/src/builder.hg: Completed the @throws lines now that GtkBuilder has documentation about the GError domains that it throws. This fixed bug #548022 (Alexander Shaduri).