diff options
author | Kirill Burtsev <kirill.burtsev@qt.io> | 2021-09-10 13:00:36 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-10 21:01:03 +0000 |
commit | 94fd97ab2c6dd0e16d72f6eb11aa7a923948e381 (patch) | |
tree | 96fc4af32ba9ce6b959266d2e9533cea969a6407 | |
parent | e2e26255dba9fe11ae709c0883d88b05294728dc (diff) |
Fix disconnect on null old page win Simple Browser example
Eliminates constant warnings from QObject on every new tab create
Change-Id: I93b3a2561a8a99932ea2a8c77cc12ded4a6906e7
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
(cherry picked from commit bfae1b143acb9581ebc9396e0ba7e7e0fe5053d0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | examples/webenginewidgets/simplebrowser/webview.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/examples/webenginewidgets/simplebrowser/webview.cpp b/examples/webenginewidgets/simplebrowser/webview.cpp index 5bd0a5ef4..31be9f34c 100644 --- a/examples/webenginewidgets/simplebrowser/webview.cpp +++ b/examples/webenginewidgets/simplebrowser/webview.cpp @@ -133,17 +133,18 @@ inline QString questionForFeature(QWebEnginePage::Feature feature) void WebView::setPage(WebPage *page) { - WebPage *oldPage = qobject_cast<WebPage *>(QWebEngineView::page()); - disconnect(oldPage, &WebPage::createCertificateErrorDialog, this, - &WebView::handleCertificateError); - disconnect(oldPage, &QWebEnginePage::authenticationRequired, this, - &WebView::handleAuthenticationRequired); - disconnect(oldPage, &QWebEnginePage::featurePermissionRequested, this, - &WebView::handleFeaturePermissionRequested); - disconnect(oldPage, &QWebEnginePage::proxyAuthenticationRequired, this, - &WebView::handleProxyAuthenticationRequired); - disconnect(oldPage, &QWebEnginePage::registerProtocolHandlerRequested, this, - &WebView::handleRegisterProtocolHandlerRequested); + if (auto oldPage = qobject_cast<WebPage *>(QWebEngineView::page())) { + disconnect(oldPage, &WebPage::createCertificateErrorDialog, this, + &WebView::handleCertificateError); + disconnect(oldPage, &QWebEnginePage::authenticationRequired, this, + &WebView::handleAuthenticationRequired); + disconnect(oldPage, &QWebEnginePage::featurePermissionRequested, this, + &WebView::handleFeaturePermissionRequested); + disconnect(oldPage, &QWebEnginePage::proxyAuthenticationRequired, this, + &WebView::handleProxyAuthenticationRequired); + disconnect(oldPage, &QWebEnginePage::registerProtocolHandlerRequested, this, + &WebView::handleRegisterProtocolHandlerRequested); + } createWebActionTrigger(page,QWebEnginePage::Forward); createWebActionTrigger(page,QWebEnginePage::Back); createWebActionTrigger(page,QWebEnginePage::Reload); |