Code

Handle case when an icon is not populated
authorjoncruz <joncruz@users.sourceforge.net>
Sun, 19 Apr 2009 01:01:03 +0000 (01:01 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Sun, 19 Apr 2009 01:01:03 +0000 (01:01 +0000)
src/ui/widget/dock-item.cpp

index 12a0686f039b2fcd3dd2486557389436df3003af..147bd818d5bda15a1cfbdebc96e1f3779fa37ace 100644 (file)
@@ -52,8 +52,15 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l
                 sp_icon_fetch_pixbuf(sp_icon);
                 _icon_pixbuf = Glib::wrap(sp_icon->pb, true);
             } else if ( GTK_IS_IMAGE(icon->gobj()) ) {
-                _icon_pixbuf = Gtk::Invisible().render_icon(Gtk::StockID(icon_name),
-                                                            Gtk::ICON_SIZE_MENU);
+                GtkStockItem stock;
+                if ( gtk_stock_lookup( icon_name.c_str(), &stock ) ) {
+                    _icon_pixbuf = Gtk::Invisible().render_icon( Gtk::StockID(icon_name),
+                                                                 Gtk::ICON_SIZE_MENU );
+                } else {
+                    // TODO re-work this properly. Anti-crasher "null" icon for the moment
+                    _icon_pixbuf = Gtk::Invisible().render_icon( Gtk::StockID(GTK_STOCK_MISSING_IMAGE),
+                                                                 Gtk::ICON_SIZE_MENU );
+                }
             }
             delete icon;