work around for null byte issue after truncating
This commit is contained in:
@@ -43,6 +43,14 @@ class FilterTask(QRunnable):
|
|||||||
# print("starting thread ", threading.currentThread())
|
# print("starting thread ", threading.currentThread())
|
||||||
self.on_before()
|
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()
|
||||||
|
|
||||||
for listener in self.filter_match_found_listeners:
|
for listener in self.filter_match_found_listeners:
|
||||||
listener(-1, -1) # notify listeners that a new search started
|
listener(-1, -1) # notify listeners that a new search started
|
||||||
|
|
||||||
@@ -138,6 +146,9 @@ class FilterWidget(QWidget):
|
|||||||
if self.filter_task:
|
if self.filter_task:
|
||||||
# print("cancel started ", time.time())
|
# print("cancel started ", time.time())
|
||||||
self.filter_task.aborted = True
|
self.filter_task.aborted = True
|
||||||
|
# wait until the previous search is aborted
|
||||||
|
with self._lock:
|
||||||
|
pass
|
||||||
|
|
||||||
def reset_filter(self):
|
def reset_filter(self):
|
||||||
self.filter_model.truncate()
|
self.filter_model.truncate()
|
||||||
|
|||||||
Reference in New Issue
Block a user