Skip to content

Commit c43de69

Browse files
committed
Cache annot styles per library
Fixes #2154593 [New 'Restrict to" annotations browser dropdown won't list custom styles](https://bugs.launchpad.net/calibre/+bug/2154593)
1 parent 367140f commit c43de69

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/calibre/gui2/library/annotations.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ class Restrictions(QWidget):
777777
def __init__(self, parent, group_by):
778778
self.restrict_to_book_ids = frozenset()
779779
self.icon_size = 12
780+
self.annotation_style_cache = {}
780781
QWidget.__init__(self, parent)
781782
v = QVBoxLayout(self)
782783
v.setContentsMargins(0, 0, 0, 0)
@@ -867,7 +868,9 @@ def re_initialize(self, db, restrict_to_book_ids=None):
867868
is_dark = is_dark_theme()
868869
model = tb.model()
869870
highlight_color_row = 1
870-
all_styles = db.all_annotation_styles()
871+
all_styles = self.annotation_style_cache.get(db.library_id)
872+
if all_styles is None:
873+
all_styles = self.annotation_style_cache[db.library_id] = db.all_annotation_styles()
871874
translate = _
872875
for style_name, style in all_styles.items():
873876
# Custom styles store their display name in friendly_name;

0 commit comments

Comments
 (0)