Re: [PATCH] 565447 Add application icons in process list



>> +        NEMIVER_TRY
>> +
>> +        THROW_IF_FAIL (a_cell);
>> +        Gtk::CellRendererPixbuf &renderer =
>> +            static_cast<Gtk::CellRendererPixbuf&> (*a_cell);
>> +
>> +        Glib::RefPtr<Gtk::IconTheme> theme = Gtk::IconTheme::get_default ();
>> +        THROW_IF_FAIL (theme);
>> +
>> +        Glib::RefPtr<Gdk::Pixbuf> icon =
>> +            theme->load_icon ("application-x-executable",
>> +                              APP_ICON_SIZE,
>> +                              Gtk::ICON_LOOKUP_USE_BUILTIN);
>> +
>> +        THROW_IF_FAIL (a_iter);
>> +        IProcMgr::Process proc;
>> +        if (proc_mgr.get_process_from_pid
>> +                (a_iter->get_value (columns ().pid), proc)
>> +            && proc.args ().size ()) {
>> +            UString process_name = proc.args ().front ();
>> +            std::vector<UString> split = str_utils::split (process_name, "/");
>> +
>> +            if (split.size ()) {
>> +                process_name = split[split.size () - 1];
>> +                try {
>> +                    icon = theme->load_icon (process_name,
>> +                                             APP_ICON_SIZE,
>> +                                             Gtk::ICON_LOOKUP_USE_BUILTIN);
>> +                } catch (Gtk::IconThemeError&) {
>> +                }
>
> Maybe add a catch (...) clause to avoid terminating the program if
> theme->load_icon throws an exception that is not compatible with
> Gtk::IconThemeError?

The entire function is inside a NEMIVER_TRY - NEMIVER_CATCH block, so
incompatible exception with Gtk::IconThemeError will still be caught.

+    void
+    proc_args_cell_data_func (Gtk::CellRenderer *a_cell,
+                              const Gtk::TreeModel::iterator &a_iter)
+    {
+        NEMIVER_TRY
...
+        NEMIVER_CATCH
+    }

I catch only Gtk::IconThemeError at this point because it's the error
throwed when gtk+ can't find the icon associated with the application.
In the case I catch it I use the default icon, otherwise I use the
application icon, and in case another error happen I let the
NEMIVER_CATCH catch it ant log the message.

Fabien


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]