reset filter only after cancelling the search

Fixes issue where the UI froze when removing the last char of a query while still a search was running. This caused the search thread to append to the newly truncated file, resulting in megabytes of null bytes at the beginning.
This commit is contained in:
2021-12-10 15:58:51 +01:00
parent 6e6029f6a2
commit e4324b03b4

View File

@@ -43,11 +43,6 @@ class FilterTask(QRunnable):
# print("starting thread ", threading.currentThread())
self.on_before()
# delay the filtering. This work arounds a race condition. For some reasons, even though we have locks
# to ensure that only one thread writes to the target file, it happened that the file was not correctly
# truncated and started with null bytes. Sometimes several MB of null bytes. My guess is that this is
# caused by async write operations.
time.sleep(0.5)
if self.aborted:
self.on_finish()
@@ -160,13 +155,14 @@ class FilterWidget(QWidget):
query = self.query_field.text()
ignore_case = self.ignore_case.isChecked()
is_regex = self.is_regex.isChecked()
if len(query) == 0:
self.reset_filter()
return
# cancel previous search
self._cancel_search()
if len(query) == 0:
self.reset_filter()
return
try:
flags = re.IGNORECASE if ignore_case else 0
if is_regex: