From 70faad3429eee7bc2be4d457b490af7c4899c58d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 11 Nov 2015 22:29:33 +0100 Subject: [PATCH] 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. See https://github.com/wxWidgets/wxWidgets/pull/129 (this is a backport of e1f31febadea7d6277c7ee92c424ae7581e1d6d1 from master) --- src/gtk/app.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 1081401c6d..d1e5899389 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -491,7 +491,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();