From 70c8979223bd758e13324800cc4ae847c4e41153 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 21 Oct 2017 23:38:46 +0200 Subject: [PATCH] Add wxCHECK_MSG() to wxGTK RunScript() implementation too Don't crash if RunScript() is called on a not yet created object. This is also consistent with the macOS version of the code. --- src/gtk/webview_webkit.cpp | 3 +++ src/gtk/webview_webkit2.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/gtk/webview_webkit.cpp b/src/gtk/webview_webkit.cpp index 5f82094ec4..ea0eb0d967 100644 --- a/src/gtk/webview_webkit.cpp +++ b/src/gtk/webview_webkit.cpp @@ -951,6 +951,9 @@ wxString wxWebViewWebKit::GetPageText() const bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output) { + wxCHECK_MSG( m_web_view, false, + wxS("wxWebView must be created before calling RunScript()") ); + if ( output != NULL ) { wxLogWarning(_("Retrieving JavaScript script output is not supported with WebKit v1")); diff --git a/src/gtk/webview_webkit2.cpp b/src/gtk/webview_webkit2.cpp index ebc67fcb85..a8c8cb1280 100644 --- a/src/gtk/webview_webkit2.cpp +++ b/src/gtk/webview_webkit2.cpp @@ -1172,6 +1172,9 @@ bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output) { + wxCHECK_MSG( m_web_view, false, + wxS("wxWebView must be created before calling RunScript()") ); + wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount); wxString result;