mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04: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
@ -129,6 +129,7 @@ class CoverCache(Thread): # {{{
|
|||||||
self.keep_running = True
|
self.keep_running = True
|
||||||
self.cache = {}
|
self.cache = {}
|
||||||
self.lock = RLock()
|
self.lock = RLock()
|
||||||
|
self.allowed_ids = frozenset([])
|
||||||
self.null_image = QImage()
|
self.null_image = QImage()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
@ -175,6 +176,9 @@ class CoverCache(Thread): # {{{
|
|||||||
break
|
break
|
||||||
for id_ in ids:
|
for id_ in ids:
|
||||||
time.sleep(0.050) # Limit 20/second to not overwhelm the GUI
|
time.sleep(0.050) # Limit 20/second to not overwhelm the GUI
|
||||||
|
with self.lock:
|
||||||
|
if id_ not in self.allowed_ids:
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
img = self._image_for_id(id_)
|
img = self._image_for_id(id_)
|
||||||
except:
|
except:
|
||||||
@ -193,6 +197,7 @@ class CoverCache(Thread): # {{{
|
|||||||
|
|
||||||
def set_cache(self, ids):
|
def set_cache(self, ids):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
|
self.allowed_ids = frozenset(ids)
|
||||||
already_loaded = set([])
|
already_loaded = set([])
|
||||||
for id in self.cache.keys():
|
for id in self.cache.keys():
|
||||||
if id in ids:
|
if id in ids:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user