mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-30 16:53:07 +02:00
Fix bug in cover cache that could cause it to keep a large number of covers in memory. Showed up when adding large numbers of books to calibre. Fixes #7813 (errors found in terminal after latest stable Calibre closed)
This commit is contained in:
parent
bb14142bec
commit
e126ddc518
1 changed files with 5 additions and 0 deletions
|
|
@ -129,6 +129,7 @@ def __init__(self, db, cover_func):
|
|||
self.keep_running = True
|
||||
self.cache = {}
|
||||
self.lock = RLock()
|
||||
self.allowed_ids = frozenset([])
|
||||
self.null_image = QImage()
|
||||
|
||||
def stop(self):
|
||||
|
|
@ -175,6 +176,9 @@ def run(self):
|
|||
break
|
||||
for id_ in ids:
|
||||
time.sleep(0.050) # Limit 20/second to not overwhelm the GUI
|
||||
with self.lock:
|
||||
if id_ not in self.allowed_ids:
|
||||
continue
|
||||
try:
|
||||
img = self._image_for_id(id_)
|
||||
except:
|
||||
|
|
@ -193,6 +197,7 @@ def run(self):
|
|||
|
||||
def set_cache(self, ids):
|
||||
with self.lock:
|
||||
self.allowed_ids = frozenset(ids)
|
||||
already_loaded = set([])
|
||||
for id in self.cache.keys():
|
||||
if id in ids:
|
||||
|
|
|
|||
Loading…
Reference in a new issue