From 65d9d72588dd013c826343cb2f8c06416ab931e6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 16 Apr 2020 08:35:00 +0530 Subject: [PATCH] Fix #1873045 [Calibre - 'NoneType' object is not iterable](https://bugs.launchpad.net/calibre/+bug/1873045) --- src/calibre/gui2/library/models.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index 5592406088..d7dcdd1f20 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -928,10 +928,6 @@ def data(self, index, role): id_ = self.id(index) self.column_color.mi = None - if self.color_row_fmt_cache is None: - self.color_row_fmt_cache = tuple(fmt for key, fmt in - self.db.prefs['column_color_rules'] if key == color_row_key) - for k, fmt in self.db.prefs['column_color_rules']: if k == key: ccol = self.column_color(id_, key, fmt, self.db, @@ -954,6 +950,9 @@ def data(self, index, role): except: pass + if self.color_row_fmt_cache is None: + self.color_row_fmt_cache = tuple(fmt for key, fmt in + self.db.prefs['column_color_rules'] if key == color_row_key) for fmt in self.color_row_fmt_cache: ccol = self.column_color(id_, color_row_key, fmt, self.db, self.color_cache, self.color_template_cache)