[pitivi/1.0] previewers: Handle thumbnail not needed anymore
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/1.0] previewers: Handle thumbnail not needed anymore
- Date: Mon, 16 Jul 2018 11:21:58 +0000 (UTC)
commit f0b499a275fb5b4309af45b8c80fcea257a61569
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Tue May 29 21:45:41 2018 +0200
previewers: Handle thumbnail not needed anymore
By the time a thumbnail is done, it's possible we don't need it anymore.
pitivi/timeline/previewers.py | 9 +++++++--
tests/test_previewers.py | 2 +-
2 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/timeline/previewers.py b/pitivi/timeline/previewers.py
index 6d621034..9a947b10 100644
--- a/pitivi/timeline/previewers.py
+++ b/pitivi/timeline/previewers.py
@@ -633,7 +633,12 @@ class VideoPreviewer(Previewer, Zoomable, Loggable):
position = self.position
self.position = -1
- thumb = self.thumbs[position]
+ try:
+ thumb = self.thumbs[position]
+ except KeyError:
+ # Can happen because we don't stop the pipeline before
+ # updating the thumbnails in _update_thumbnails.
+ return
thumb.set_from_pixbuf(pixbuf)
self.thumb_cache[position] = pixbuf
self.queue_draw()
@@ -829,7 +834,7 @@ class ThumbnailCache(Loggable):
Returns:
List[int]: The width and height of the images in the cache.
"""
- if self._image_size[0] is None:
+ if self._image_size[0] is 0:
self._cur.execute("SELECT * FROM Thumbs LIMIT 1")
row = self._cur.fetchone()
if row:
diff --git a/tests/test_previewers.py b/tests/test_previewers.py
index ff705112..0d3c9912 100644
--- a/tests/test_previewers.py
+++ b/tests/test_previewers.py
@@ -148,7 +148,7 @@ class TestThumbnailCache(BaseTestMediaLibrary):
xdg_cache_home.return_value = tmpdirname
sample_uri = common.get_sample_uri("1sec_simpsons_trailer.mp4")
thumb_cache = ThumbnailCache(sample_uri)
- self.assertEqual(thumb_cache.image_size, (None, None))
+ self.assertEqual(thumb_cache.image_size, (0, 0))
pixbuf = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB,
False, 8, 20, 10)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]