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 143018 - Gtk::IconTheme::lookup_icon() should throw an exception if gtk_icon_theme_lookup_icon() returns NULL
Gtk::IconTheme::lookup_icon() should throw an exception if gtk_icon_theme_loo...
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
2.4
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2004-05-23 22:47 UTC by Chris Vine
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Chris Vine 2004-05-23 22:47:55 UTC
Gtk::IconTheme::lookup_icon wraps the gtk_icon_info pointer returned by 
gtk_icon_theme_lookup_icon().  The C function returns a NULL value for the 
pointer if the icon searched for cannot be found: accordingly a null 
Gtk::IconInfo object is returned where the C function fails. 
 
However, there is no Gtk::IconInfo::operator bool() function to test the 
validity of the Gtk::IconInfo object, and in any event it would be better to 
throw an exception, like Gtk::IconTheme::load_icon().
Comment 1 Murray Cumming 2004-06-03 09:28:36 UTC
I would not like to add an exception where there is no corresponding GError in
the C function. Well, maybe, but we need to be consistent about when we throw an
error and when we return an invalid instance - just mapping GTK+ means we don't
need to decide about that.

So, adding operator bool() is probably the correct fix here. A patch would be
welcome, as an API addition for a future gtkmm 2.5/2.6.

As a workaround for now, you can check gobj() for 0.

This bug might also be interesting:
http://bugzilla.gnome.org/show_bug.cgi?id=143632
Comment 2 Chris Vine 2004-06-05 10:34:21 UTC
I can do a patch.  Is an operator!() also required? 
Comment 3 Chris Vine 2004-06-05 11:07:27 UTC
On reflection, if we have an operator bool(), then operator !() is not
necessary.  It would only be useful if we were to test the object with operator
void*().
Comment 4 Murray Cumming 2004-06-06 11:23:18 UTC
Yes, other gtkmm classes just have operator bool().
Comment 5 Murray Cumming 2004-11-17 20:47:17 UTC
Done in HEAD.

2004-11-17  Murray Cumming  <murrayc@murayc.com>
 
        * gtk/src/iconinfo.[hg|ccg]: Added operator bool(), needed to check
        the result of IconTheme::lookup_icon(). Bug #143018.