Fix crash with GTK+ 2 in wxMimeTypesManager code
Fix the crash introduced by 4dfde501df
: we can't
use g_object_unref() to free GtkIconInfo with GTK+ 2.
See https://github.com/wxWidgets/wxWidgets/pull/293
This commit is contained in:
@@ -31,17 +31,30 @@ wxString wxGTKMimeTypesManagerImpl::GetIconFromMimeType(const wxString& mime)
|
|||||||
if ( !theme )
|
if ( !theme )
|
||||||
return wxString();
|
return wxString();
|
||||||
|
|
||||||
wxGtkObject<GtkIconInfo> giconinfo(gtk_icon_theme_lookup_by_gicon
|
// 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
|
||||||
theme,
|
// using wxGtkObject when support for GTK+ 2 is dropped.
|
||||||
gicon,
|
GtkIconInfo* const giconinfo = gtk_icon_theme_lookup_by_gicon
|
||||||
256,
|
(
|
||||||
GTK_ICON_LOOKUP_NO_SVG
|
theme,
|
||||||
));
|
gicon,
|
||||||
if ( !giconinfo )
|
256,
|
||||||
return wxString();
|
GTK_ICON_LOOKUP_NO_SVG
|
||||||
|
);
|
||||||
|
|
||||||
return wxString::FromUTF8(gtk_icon_info_get_filename(giconinfo));
|
wxString icon;
|
||||||
|
if ( giconinfo )
|
||||||
|
{
|
||||||
|
icon = wxString::FromUTF8(gtk_icon_info_get_filename(giconinfo));
|
||||||
|
|
||||||
|
#ifdef __WXGTK3__
|
||||||
|
g_object_unref(giconinfo);
|
||||||
|
#else
|
||||||
|
gtk_icon_info_free(giconinfo);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMimeTypesManagerImpl *wxGTKMimeTypesManagerFactory::CreateMimeTypesManagerImpl()
|
wxMimeTypesManagerImpl *wxGTKMimeTypesManagerFactory::CreateMimeTypesManagerImpl()
|
||||||
|
Reference in New Issue
Block a user