summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/web_contents_delegate_qt.cpp1
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp11
2 files changed, 9 insertions, 3 deletions
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 97f0e515d..5e9157069 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -97,6 +97,7 @@ content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents
if (targetAdapter)
target = targetAdapter->webContents();
}
+ Q_ASSERT(target);
content::NavigationController::LoadURLParams load_url_params(params.url);
load_url_params.referrer = params.referrer;
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index dbbac1aed..f10833b9b 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -279,9 +279,14 @@ void QWebEnginePagePrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> ne
if (newPage->d_func() == this) {
// If createWindow returns /this/ we must delay the adoption.
Q_ASSERT(q == newPage);
- QTimer::singleShot(0, q, [this, newPage, newWebContents, initialGeometry] () {
- adoptNewWindowImpl(newPage, newWebContents, initialGeometry);
- });
+ // WebContents might be null if we just opened a new page for navigation, in that case
+ // avoid referencing newWebContents so that it is deleted and WebContentsDelegateQt::OpenURLFromTab
+ // will fall back to navigating current page.
+ if (newWebContents->webContents()) {
+ QTimer::singleShot(0, q, [this, newPage, newWebContents, initialGeometry] () {
+ adoptNewWindowImpl(newPage, newWebContents, initialGeometry);
+ });
+ }
} else {
adoptNewWindowImpl(newPage, newWebContents, initialGeometry);
}