[pitivi/1.0] previewers: Fix thumbnail generation when cache db empty

commit c5434a12ff201f4622a2d881de8739a3564a87b8
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Sun Jul 8 04:43:00 2018 +0200

    previewers: Fix thumbnail generation when cache db empty
    When the thumbnail cache db is empty, the returned image_size is (None,
    None) so thumb_width is set to None, but when there is no cache db, we
    initialize it with 0. That's why thumbnail generation somehow worked for
    new media files.
    Fixed by using consistently 0 instead of None, and always starting the
    pipeline when there is no db or the db is empty, as starting the
    pipeline sets thumb_width.

 pitivi/timeline/previewers.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/pitivi/timeline/previewers.py b/pitivi/timeline/previewers.py
index d7e96805..6d621034 100644
--- a/pitivi/timeline/previewers.py
+++ b/pitivi/timeline/previewers.py
@@ -539,6 +539,11 @@ class VideoPreviewer(Previewer, Zoomable, Loggable):
+            if not self.thumb_width:
+                self.debug("Finding thumb width")
+                self.pipeline = self._setup_pipeline()
+                return
             # Update the thumbnails with what we already have, if anything.
             if self.queue:
@@ -585,7 +590,7 @@ class VideoPreviewer(Previewer, Zoomable, Loggable):
     def _update_thumbnails(self):
         """Updates the thumbnail widgets for the clip at the current zoom."""
-        if self.thumb_width is None:
+        if not self.thumb_width:
             # The thumb_width will be available when pipeline has been started
             # or the __image_pixbuf is ready.
@@ -769,7 +774,7 @@ class ThumbnailCache(Loggable):
                           "(Time INTEGER NOT NULL PRIMARY KEY, "
                           " Jpeg BLOB NOT NULL)")
         # The cached (width, height) of the images.
-        self._image_size = (None, None)
+        self._image_size = (0, 0)
         # The cached positions available in the database.
         self.positions = self.__existing_positions()
         # The ID of the autosave event.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]