From ec84507898e58a167b185ba674acf300cc695380 Mon Sep 17 00:00:00 2001 From: Christophe Chapuis Date: Sun, 4 Sep 2016 14:37:57 +0000 Subject: Fix crash when using openIn on newly created view When a link triggers a NewViewRequest, and the latter creates a new window with a new WebEngineView inside, the "adapter" pointer can still be NULL when the adoptWebContents is called by openIn. Therefore is it necessary to test the adapter pointer before using it. (cherry picked from commit bfc2683ab4ca3f56a2effd1b2f7e68850acb72ba) Task-number: QTBUG-55765 Change-Id: Iaa7cb4e8c7780a2e3f1a8c85b7b5da0ec541b2f3 Reviewed-by: Jani Heikkinen --- src/webengine/api/qquickwebengineview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 68dfae145..4eca71926 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -755,8 +755,10 @@ void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContent // This throws away the WebContentsAdapter that has been used until now. // All its states, particularly the loading URL, are replaced by the adopted WebContentsAdapter. - WebContentsAdapterOwner *adapterOwner = new WebContentsAdapterOwner(adapter->sharedFromThis()); - adapterOwner->deleteLater(); + if (adapter) { + WebContentsAdapterOwner *adapterOwner = new WebContentsAdapterOwner(adapter->sharedFromThis()); + adapterOwner->deleteLater(); + } adapter = webContents->sharedFromThis(); adapter->initialize(this); -- cgit v1.2.1