mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-22 22:24:56 +08:00
Add more pointer checks
Mostly for consistency with the rest of the file, along with being more overly robust
This commit is contained in:
+26
-11
@@ -216,11 +216,14 @@ public:
|
||||
return false;
|
||||
}
|
||||
// Mark event as completed
|
||||
hr = m_deferral->Complete();
|
||||
if (FAILED(hr))
|
||||
if ( m_deferral )
|
||||
{
|
||||
wxLogApiError("deferral->Complete()", hr);
|
||||
return false;
|
||||
hr = m_deferral->Complete();
|
||||
if (FAILED(hr))
|
||||
{
|
||||
wxLogApiError("deferral->Complete()", hr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -369,7 +372,8 @@ public:
|
||||
{
|
||||
wxPoint result(-1, -1);
|
||||
BOOL hasPosition;
|
||||
if (SUCCEEDED(m_windowFeatures->get_HasPosition(&hasPosition)) && hasPosition)
|
||||
if (m_windowFeatures &&
|
||||
SUCCEEDED(m_windowFeatures->get_HasPosition(&hasPosition)) && hasPosition)
|
||||
{
|
||||
UINT32 x, y;
|
||||
if (SUCCEEDED(m_windowFeatures->get_Left(&x)) &&
|
||||
@@ -383,7 +387,8 @@ public:
|
||||
{
|
||||
wxSize result(-1, -1);
|
||||
BOOL hasSize;
|
||||
if (SUCCEEDED(m_windowFeatures->get_HasSize(&hasSize)) && hasSize)
|
||||
if (m_windowFeatures &&
|
||||
SUCCEEDED(m_windowFeatures->get_HasSize(&hasSize)) && hasSize)
|
||||
{
|
||||
UINT32 width, height;
|
||||
if (SUCCEEDED(m_windowFeatures->get_Width(&width)) &&
|
||||
@@ -396,7 +401,8 @@ public:
|
||||
virtual bool ShouldDisplayMenuBar() const override
|
||||
{
|
||||
BOOL result;
|
||||
if (SUCCEEDED(m_windowFeatures->get_ShouldDisplayMenuBar(&result)))
|
||||
if (m_windowFeatures &&
|
||||
SUCCEEDED(m_windowFeatures->get_ShouldDisplayMenuBar(&result)))
|
||||
return result;
|
||||
else
|
||||
return true;
|
||||
@@ -405,7 +411,8 @@ public:
|
||||
virtual bool ShouldDisplayStatusBar() const override
|
||||
{
|
||||
BOOL result;
|
||||
if (SUCCEEDED(m_windowFeatures->get_ShouldDisplayStatus(&result)))
|
||||
if (m_windowFeatures &&
|
||||
SUCCEEDED(m_windowFeatures->get_ShouldDisplayStatus(&result)))
|
||||
return result;
|
||||
else
|
||||
return true;
|
||||
@@ -413,7 +420,8 @@ public:
|
||||
virtual bool ShouldDisplayToolBar() const override
|
||||
{
|
||||
BOOL result;
|
||||
if (SUCCEEDED(m_windowFeatures->get_ShouldDisplayToolbar(&result)))
|
||||
if (m_windowFeatures &&
|
||||
SUCCEEDED(m_windowFeatures->get_ShouldDisplayToolbar(&result)))
|
||||
return result;
|
||||
else
|
||||
return true;
|
||||
@@ -422,7 +430,8 @@ public:
|
||||
virtual bool ShouldDisplayScrollBars() const override
|
||||
{
|
||||
BOOL result;
|
||||
if (SUCCEEDED(m_windowFeatures->get_ShouldDisplayScrollBars(&result)))
|
||||
if (m_windowFeatures &&
|
||||
SUCCEEDED(m_windowFeatures->get_ShouldDisplayScrollBars(&result)))
|
||||
return result;
|
||||
else
|
||||
return true;
|
||||
@@ -1005,7 +1014,7 @@ HRESULT wxWebViewEdgeImpl::OnWebViewCreated(HRESULT result, ICoreWebView2Control
|
||||
{
|
||||
if (FAILED(m_newWindowArgs->put_NewWindow(baseWebView)))
|
||||
SendErrorEventForAPI("WebView2::WebViewCreated (put_NewWindow)", hr);
|
||||
if (FAILED(m_newWindowDeferral->Complete()))
|
||||
if (m_newWindowDeferral && FAILED(m_newWindowDeferral->Complete()))
|
||||
SendErrorEventForAPI("WebView2::WebViewCreated (Complete)", hr);
|
||||
m_newWindowArgs.reset();
|
||||
m_newWindowDeferral.reset();
|
||||
@@ -1631,6 +1640,9 @@ void wxWebViewEdge::EnableAccessToDevTools(bool enable)
|
||||
|
||||
bool wxWebViewEdge::ShowDevTools()
|
||||
{
|
||||
if ( !m_impl->m_webView )
|
||||
return false;
|
||||
|
||||
const HRESULT hr = m_impl->m_webView->OpenDevToolsWindow();
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
@@ -1718,6 +1730,9 @@ bool wxWebViewEdge::SetProxy(const wxString& proxy)
|
||||
|
||||
bool wxWebViewEdge::ClearBrowsingData(int types, wxDateTime since)
|
||||
{
|
||||
if ( !m_impl->m_webView )
|
||||
return false;
|
||||
|
||||
wxCOMPtr<ICoreWebView2_13> webView13;
|
||||
if (FAILED(m_impl->m_webView->QueryInterface(IID_PPV_ARGS(&webView13))))
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user