After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 548022 - Gtk::Builder::get_widget(): Incomplete documentation about exceptions thrown
Gtk::Builder::get_widget(): Incomplete documentation about exceptions thrown
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
2.12.x
Other All
: Normal critical
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on: 560147
Blocks:
 
 
Reported: 2008-08-16 13:57 UTC by Alexander Shaduri
Modified: 2010-04-07 13:41 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Alexander Shaduri 2008-08-16 13:57:30 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:
  • #0 Gtk::Builder::get_widget_checked
    from /usr/lib/libgtkmm-2.4.so.1
  • #1 Gtk::Builder::get_widget<Gtk::Dialog>
  • #2 main


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.
Comment 1 Murray Cumming 2008-11-10 14:28:16 UTC
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.
Comment 2 Alexander Shaduri 2009-07-21 10:08:12 UTC
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)?
Comment 3 Murray Cumming 2009-07-21 13:40:25 UTC
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.
Comment 4 Alexander Shaduri 2009-07-21 16:06:43 UTC
(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.
Comment 5 Murray Cumming 2009-07-21 16:16:50 UTC
(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?


Comment 6 Alexander Shaduri 2009-07-21 16:37:33 UTC
(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.
Comment 7 Murray Cumming 2010-04-07 13:41:26 UTC
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).