Write-lock when refiltering

This commit is contained in:
miruka 2020-05-06 13:47:28 -04:00
parent c502aa4245
commit 0e49b5f972
2 changed files with 15 additions and 13 deletions

View File

@ -11,6 +11,7 @@
- fix left rooms opacity
- fix escape keybinds (filter rooms, message selection)
- fix nio 429
- fix python getting stuck when loading large room
- account delegates refactor
- lag when switching accounts

View File

@ -55,23 +55,24 @@ class ModelFilter(ModelProxy):
def refilter(self) -> None:
take_out = []
bring_back = []
with self._write_lock:
take_out = []
bring_back = []
for key, item in sorted(self.items(), key=lambda kv: kv[1]):
if not self.accept_item(item):
take_out.append(key)
for key, item in sorted(self.items(), key=lambda kv: kv[1]):
if not self.accept_item(item):
take_out.append(key)
for key, item in self.filtered_out.items():
if self.accept_item(item):
bring_back.append(key)
for key, item in self.filtered_out.items():
if self.accept_item(item):
bring_back.append(key)
with self.batch_remove():
for key in take_out:
self.filtered_out[key] = self.pop(key)
with self.batch_remove():
for key in take_out:
self.filtered_out[key] = self.pop(key)
for key in bring_back:
self[key] = self.filtered_out.pop(key)
for key in bring_back:
self[key] = self.filtered_out.pop(key)
class FieldSubstringFilter(ModelFilter):