From 9d6bd9a52d4caa1539330aa2e6e2d185f99158ad Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 22 Oct 2017 00:35:29 +0200 Subject: [PATCH] Fix webkit_web_view_run_javascript() callback signature Don't use wrong types and then cast the function pointer to the right type, but just use the correct type from the beginning. Also make the callback extern "C", as it should be, to be called from C code. --- src/gtk/webview_webkit2.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gtk/webview_webkit2.cpp b/src/gtk/webview_webkit2.cpp index 59fa602c63..ff5076fffc 100644 --- a/src/gtk/webview_webkit2.cpp +++ b/src/gtk/webview_webkit2.cpp @@ -1099,17 +1099,21 @@ wxString wxWebViewWebKit::GetPageText() const return wxString(); } -static void wxgtk_run_javascript_cb(WebKitWebView *, - GAsyncResult *res, - GAsyncResult **res_out) +extern "C" +{ + +static void wxgtk_run_javascript_cb(GObject *, + GAsyncResult *res, + void *user_data) { - // Ensure that it doesn't get freed by the time we use it in - // RunScriptSync() itself. g_object_ref(res); + GAsyncResult** res_out = static_cast(user_data); *res_out = res; } +} // extern "C" + // Run the given script synchronously and return its result in output. bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output) { @@ -1117,7 +1121,7 @@ bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output webkit_web_view_run_javascript(m_web_view, javascript, NULL, - (GAsyncReadyCallback)wxgtk_run_javascript_cb, + wxgtk_run_javascript_cb, &result); GMainContext *main_context = g_main_context_get_thread_default();