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