diff options
author | Michal Klocek <michal.klocek@qt.io> | 2018-01-16 18:44:01 +0100 |
---|---|---|
committer | Jędrzej Nowacki <jedrzej.nowacki@qt.io> | 2018-01-31 15:58:47 +0000 |
commit | 7644564d754bbee640a091950b77e23586c2d283 (patch) | |
tree | 1c4bf0ebeb519d030f5897316dfa30fb86ae721b /src/webenginewidgets | |
parent | 1661c8179989378d5cb03f9233ce2b72c582d8c1 (diff) |
Fix crashes of url load qml tests
Currently we can get QuickWebEngineViewPrivate::loadFinished
while still being in RenderFrameHostImpl::OnDidStopLoading,
unfortunately if user connects onLoadingChanged signal
with new url load request this will end up in DiscardUnusedFrame
and delete on RenderFrameHostImpl which is still on the bottom of
the stack. Use QTimer::singleShot to return to the event loop
before emitting load handling signals.
Post all load handling calls with singleShot to avoid out of order
load "signals" delivery in some cases.
Emitting signals should be done from WebContentsAdapterClient to
make sure the destruction of WebConentAdapterClient prevents
emitting signals on already deleted adapter.
Task-numbmer: QTBUG-65813
Change-Id: I93263876fb14bd959ba951463c8aeb5155f04a4f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 3f585cf78..ac8e9c667 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -328,7 +328,7 @@ void QWebEnginePagePrivate::loadStarted(const QUrl &provisionalUrl, bool isError return; isLoading = true; - Q_EMIT q->loadStarted(); + QTimer::singleShot(0, q, &QWebEnginePage::loadStarted); updateNavigationActions(); } @@ -346,7 +346,9 @@ void QWebEnginePagePrivate::loadFinished(bool success, const QUrl &url, bool isE if (isErrorPage) { Q_ASSERT(settings->testAttribute(QWebEngineSettings::ErrorPageEnabled)); - Q_EMIT q->loadFinished(false); + QTimer::singleShot(0, q, [q](){ + emit q->loadFinished(false); + }); return; } @@ -356,7 +358,9 @@ void QWebEnginePagePrivate::loadFinished(bool success, const QUrl &url, bool isE // Delay notifying failure until the error-page is done loading. // Error-pages are not loaded on failures due to abort. if (success || errorCode == -3 /* ERR_ABORTED*/ || !settings->testAttribute(QWebEngineSettings::ErrorPageEnabled)) { - Q_EMIT q->loadFinished(success); + QTimer::singleShot(0, q, [q, success](){ + emit q->loadFinished(success); + }); } updateNavigationActions(); } |