Also add checks that CefBrowser itself is valid

Further extend the changes of the previous two commits and cover all the
functions using the possibly not yet initialized browser object.
This commit is contained in:
Vadim Zeitlin 2023-09-05 23:03:51 +02:00
parent 8d5bd418ae
commit 68c2a2b96f

View file

@ -748,18 +748,24 @@ void wxWebViewChromium::EnableHistory(bool enable)
void wxWebViewChromium::Stop()
{
m_clientHandler->GetBrowser()->StopLoad();
auto browser = m_clientHandler->GetBrowser();
wxCHECK_RET( browser, "No valid browser object" );
browser->StopLoad();
}
void wxWebViewChromium::Reload(wxWebViewReloadFlags flags)
{
auto browser = m_clientHandler->GetBrowser();
wxCHECK_RET( browser, "No valid browser object" );
if ( flags == wxWEBVIEW_RELOAD_NO_CACHE )
{
m_clientHandler->GetBrowser()->ReloadIgnoreCache();
browser->ReloadIgnoreCache();
}
else
{
m_clientHandler->GetBrowser()->Reload();
browser->Reload();
}
}
@ -870,10 +876,11 @@ bool wxWebViewChromium::RunScript(const wxString& javascript, wxString* output)
bool wxWebViewChromium::IsBusy() const
{
if(m_clientHandler->GetBrowser())
return m_clientHandler->GetBrowser()->IsLoading();
else
auto browser = m_clientHandler->GetBrowser();
if ( !browser )
return false;
return browser->IsLoading();
}
void wxWebViewChromium::SetEditable(bool enable)