summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKirill Burtsev <kirill.burtsev@qt.io>2019-07-15 13:03:14 +0200
committerKirill Burtsev <kirill.burtsev@qt.io>2019-07-16 22:47:33 +0200
commitb4589db4c7cb10cb55b38bab00d80eb1290312b1 (patch)
tree9c733e9052a946ef90ffc8fa7cff6d86d6d87c36
parent73daf5b669c943d3c7a765533c5b5d61c380a576 (diff)
Reset findText reply id on StopFinding to prevent callback later
Not updating lastReceivedFindReply caused next findText call after StopFinding to trigger redundant callback call on checking stale query. Fixes: QTBUG-77029 Change-Id: Iad4b71364ecb3ec3db3096b739e77620d12731f9 Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
-rw-r--r--src/core/web_contents_adapter.cpp2
-rw-r--r--src/core/web_contents_delegate_qt.cpp2
-rw-r--r--src/core/web_contents_delegate_qt.h1
-rw-r--r--tests/auto/quick/qmltests/data/tst_findText.qml4
4 files changed, 8 insertions, 1 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 567a76637..a342ba302 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -987,6 +987,7 @@ quint64 WebContentsAdapter::findText(const QString &subString, bool caseSensitiv
// waiting for it forever.
// Assume that any unfinished find has been unsuccessful when a new one is started
// to cover that case.
+ m_webContentsDelegate->setLastReceivedFindReply(m_lastFindRequestId);
m_adapterClient->didFindText(m_lastFindRequestId, 0);
}
@@ -1007,6 +1008,7 @@ quint64 WebContentsAdapter::findText(const QString &subString, bool caseSensitiv
void WebContentsAdapter::stopFinding()
{
CHECK_INITIALIZED();
+ m_webContentsDelegate->setLastReceivedFindReply(m_lastFindRequestId);
m_webContentsDelegate->setLastSearchedString(QString());
m_webContents->StopFinding(content::STOP_FIND_ACTION_KEEP_SELECTION);
}
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 83f68b68d..20de0546f 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -510,7 +510,7 @@ void WebContentsDelegateQt::FindReply(content::WebContents *source, int request_
Q_UNUSED(source)
Q_UNUSED(selection_rect)
Q_UNUSED(active_match_ordinal)
- if (final_update) {
+ if (final_update && request_id > m_lastReceivedFindReply) {
m_lastReceivedFindReply = request_id;
m_viewClient->didFindText(request_id, number_of_matches);
}
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 27aac2071..b88b56dc1 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -114,6 +114,7 @@ public:
QString lastSearchedString() const { return m_lastSearchedString; }
void setLastSearchedString(const QString &s) { m_lastSearchedString = s; }
int lastReceivedFindReply() const { return m_lastReceivedFindReply; }
+ void setLastReceivedFindReply(int id) { m_lastReceivedFindReply = id; }
QUrl url() const { return m_url; }
QString title() const { return m_title; }
diff --git a/tests/auto/quick/qmltests/data/tst_findText.qml b/tests/auto/quick/qmltests/data/tst_findText.qml
index 9687d9183..93aa48365 100644
--- a/tests/auto/quick/qmltests/data/tst_findText.qml
+++ b/tests/auto/quick/qmltests/data/tst_findText.qml
@@ -222,6 +222,10 @@ TestWebEngineView {
expectFailContinue('', 'No unexpected findText callback calls occurred.')
tryVerify(function() { return webEngineView.findCallbackCalled() })
verify(!webEngineView.findCallbackCalled())
+
+ webEngineView.clear();
+ webEngineView.findText('New page', findFlags, webEngineView.findTextCallback)
+ tryCompare(webEngineView, 'matchCount', 1)
}
}
}