Also fix crash with GTK+ < 3.8 in wxMimeTypesManager code

GtkIconInfo is not a GObject prior to 3.8, not just in GTK+ 2.
See https://github.com/wxWidgets/wxWidgets/pull/293
This commit is contained in:
Paul Cornett 2016-06-08 21:15:41 -07:00
parent c4d06e8117
commit c3a224690e

View File

@ -21,19 +21,19 @@
wxString wxGTKMimeTypesManagerImpl::GetIconFromMimeType(const wxString& mime)
{
wxString icon;
wxGtkString type(g_content_type_from_mime_type(mime.utf8_str()));
wxGtkObject<GIcon> gicon(g_content_type_get_icon(type));
if ( !gicon )
return wxString();
return icon;
GtkIconTheme *theme(gtk_icon_theme_get_default());
if ( !theme )
return wxString();
return icon;
// Notice that we can't use wxGtkObject here because a special function
// needs to be used for freeing this object in GTK+ 2. We should switch to
// using wxGtkObject when support for GTK+ 2 is dropped.
// needs to be used for freeing this object prior to GTK+ 3.8.
GtkIconInfo* const giconinfo = gtk_icon_theme_lookup_by_gicon
(
theme,
@ -42,16 +42,13 @@ wxString wxGTKMimeTypesManagerImpl::GetIconFromMimeType(const wxString& mime)
GTK_ICON_LOOKUP_NO_SVG
);
wxString icon;
if ( giconinfo )
{
icon = wxString::FromUTF8(gtk_icon_info_get_filename(giconinfo));
#ifdef __WXGTK3__
g_object_unref(giconinfo);
#else
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
gtk_icon_info_free(giconinfo);
#endif
wxGCC_WARNING_RESTORE()
}
return icon;