From fbcf17eae574d59b57ddefc7bd6467e7addf3927 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev <kirill.burtsev@qt.io> Date: Wed, 29 Aug 2018 15:19:41 +0200 Subject: [PATCH] Fix QWebEnginePage emit zero loadProgress before loadStarted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restore expected behavior for QWebEnginePage loading progress. This was missing after queuing progress notification signals change. Add missing state transition to loadSignalsOrder test. Change-Id: Id1d94f8391b83decc8057c5108d2d19c38258965 Reviewed-by: Michael Brüning <michael.bruning@qt.io> Reviewed-by: Michal Klocek <michal.klocek@qt.io> --- src/webenginewidgets/api/qwebenginepage.cpp | 2 +- tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 3d8f9389a..187565a76 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -322,7 +322,7 @@ void QWebEnginePagePrivate::iconChanged(const QUrl &url) void QWebEnginePagePrivate::loadProgressChanged(int progress) { Q_Q(QWebEnginePage); - Q_EMIT q->loadProgress(progress); + QTimer::singleShot(0, q, [q, progress] () { Q_EMIT q->loadProgress(progress); }); } void QWebEnginePagePrivate::didUpdateTargetURL(const QUrl &hoveredUrl) diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 8b36d5a6f..cb6e9e405 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -2216,11 +2216,13 @@ public: connect(page, SIGNAL(loadProgress(int)), SLOT(onLoadProgress(int))); QState* waitingForLoadStarted = new QState(this); + QState* waitingForFirstLoadProgress = new QState(this); QState* waitingForLastLoadProgress = new QState(this); QState* waitingForLoadFinished = new QState(this); QFinalState* final = new QFinalState(this); - waitingForLoadStarted->addTransition(page, SIGNAL(loadStarted()), waitingForLastLoadProgress); + waitingForLoadStarted->addTransition(page, SIGNAL(loadStarted()), waitingForFirstLoadProgress); + waitingForFirstLoadProgress->addTransition(this, SIGNAL(firstLoadProgress()), waitingForLastLoadProgress); waitingForLastLoadProgress->addTransition(this, SIGNAL(lastLoadProgress()), waitingForLoadFinished); waitingForLoadFinished->addTransition(page, SIGNAL(loadFinished(bool)), final); @@ -2234,10 +2236,13 @@ public: public Q_SLOTS: void onLoadProgress(int progress) { - if (progress == 100) + if (progress == 0) + emit firstLoadProgress(); + else if (progress == 100) emit lastLoadProgress(); } Q_SIGNALS: + void firstLoadProgress(); void lastLoadProgress(); }; -- GitLab