Skip to content

Commit

Permalink
bugfix: Don't error if preview unsuccessfully read
Browse files Browse the repository at this point in the history
  • Loading branch information
torzdf committed Oct 23, 2022
1 parent 2e8ef5e commit d1a7f7a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/gui/utils/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,15 @@ def load(self) -> bool:

logger.debug("Loading preview: '%s'", filename)
img = cv2.imread(filename, cv2.IMREAD_UNCHANGED)
assert img is not None
self._modified = modified
self._buffer.add_image(os.path.basename(filename), img)
self._error_count = 0
except ValueError:
except (ValueError, AssertionError):
# This is probably an error reading the file whilst it's being saved so ignore it
# for now and only pick up if there have been multiple consecutive fails
logger.warning("Unable to display preview: (image: '%s', attempt: %s)",
img, self._error_count)
logger.debug("Unable to display preview: (image: '%s', attempt: %s)",
img, self._error_count)
if self._error_count < 10:
self._error_count += 1
else:
Expand Down

0 comments on commit d1a7f7a

Please sign in to comment.