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.
This commit is contained in:
Vadim Zeitlin
2017-10-21 23:38:46 +02:00
parent 9884b0b4ea
commit 70c8979223
2 changed files with 6 additions and 0 deletions

View File

@@ -951,6 +951,9 @@ wxString wxWebViewWebKit::GetPageText() const
bool wxWebViewWebKit::RunScript(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()") );
if ( output != NULL ) if ( output != NULL )
{ {
wxLogWarning(_("Retrieving JavaScript script output is not supported with WebKit v1")); wxLogWarning(_("Retrieving JavaScript script output is not supported with WebKit v1"));

View File

@@ -1172,6 +1172,9 @@ bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output
bool wxWebViewWebKit::RunScript(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); wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount);
wxString result; wxString result;