From 44b30c1a602c3eab75b49d3f94c55fb4d21e24e7 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Fri, 27 Oct 2017 10:05:43 -0700 Subject: [PATCH] Avoid use of GDBusServer object after it is destroyed --- src/gtk/webview_webkit2.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gtk/webview_webkit2.cpp b/src/gtk/webview_webkit2.cpp index 807c76d148..cc4437091d 100644 --- a/src/gtk/webview_webkit2.cpp +++ b/src/gtk/webview_webkit2.cpp @@ -391,6 +391,7 @@ wxgtk_webview_webkit_counted_matches(WebKitFindController *, *findCount = match_count; } +static bool z; static void wxgtk_initialize_web_extensions(WebKitWebContext *context, GDBusServer *dbusServer) @@ -401,6 +402,7 @@ wxgtk_initialize_web_extensions(WebKitWebContext *context, WX_WEB_EXTENSIONS_DIRECTORY); webkit_web_context_set_web_extensions_initialization_user_data(context, user_data); +z = true; } static gboolean @@ -505,6 +507,9 @@ bool wxWebViewWebKit::Create(wxWindow *parent, m_dbusServer); m_web_view = WEBKIT_WEB_VIEW(webkit_web_view_new()); + + while (!z) + gtk_main_iteration(); GTKCreateScrolledWindowWith(GTK_WIDGET(m_web_view)); g_object_ref(m_widget); @@ -552,7 +557,12 @@ wxWebViewWebKit::~wxWebViewWebKit() if (m_web_view) GTKDisconnect(m_web_view); if (m_dbusServer) + { g_dbus_server_stop(m_dbusServer); + g_signal_handlers_disconnect_matched( + webkit_web_context_get_default(), G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, m_dbusServer); + } g_clear_object(&m_dbusServer); g_clear_object(&m_extension); }