Fix GTK error wxApp::CleanUp() when GUI is not initialised

For the programs that use wxWidgets but can also run using just CLI, exiting
the program would show a bogus GTK error

GLib-GObject-CRITICAL **: g_type_class_unref: assertion 'g_class != NULL' failed

Fix this by only releasing the references to GTK_TYPE_WIDGET if we had
acquired it in the first place.

Closes https://github.com/wxWidgets/wxWidgets/pull/129
This commit is contained in:
Bronek Kozicki 2015-11-11 21:17:51 +00:00 committed by Vadim Zeitlin
parent ec2d9a2f89
commit 4ce23e5217

View File

@ -428,7 +428,9 @@ void wxApp::CleanUp()
g_source_remove(m_idleSourceId);
// release reference acquired by Initialize()
g_type_class_unref(g_type_class_peek(GTK_TYPE_WIDGET));
gpointer gt = g_type_class_peek(GTK_TYPE_WIDGET);
if (gt != NULL)
g_type_class_unref(gt);
gdk_threads_leave();