Track number of active searches in tab, ignore all but most recent search callbacks

This commit is contained in:
Justin Partain 2017-12-05 08:28:10 -05:00
parent 3a012ca1e3
commit 00a09354c3

View File

@ -126,13 +126,19 @@ class WebEngineSearch(browsertab.AbstractSearch):
def __init__(self, parent=None):
super().__init__(parent)
self._flags = QWebEnginePage.FindFlags(0)
self.num_of_searches = 0
def _find(self, text, flags, callback, caller):
"""Call findText on the widget."""
self.search_displayed = True
self.num_of_searches += 1
def wrapped_callback(found):
"""Wrap the callback to do debug logging."""
self.num_of_searches -= 1
if self.num_of_searches > 0:
return
found_text = 'found' if found else "didn't find"
if flags:
flag_text = 'with flags {}'.format(debug.qflags_key(