[pitivi] Viewer: Protect seeks with try/except



commit 117d0b4a1a6a1bef8d7b86d9a29e5dc84f037317
Author: Edward Hervey <bilboed bilboed com>
Date:   Wed May 20 12:11:18 2009 +0200

    Viewer: Protect seeks with try/except
---
 pitivi/ui/viewer.py |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/pitivi/ui/viewer.py b/pitivi/ui/viewer.py
index 3e1d960..0604f71 100644
--- a/pitivi/ui/viewer.py
+++ b/pitivi/ui/viewer.py
@@ -349,7 +349,10 @@ class PitiviViewer(gtk.VBox, Loggable):
         self.seekRelative(amount)
 
     def seek(self, position, format=gst.FORMAT_TIME):
-        self.seeker.seek(position, format)
+        try:
+            self.seeker.seek(position, format)
+        except:
+            self.warning("seek failed")
 
     def _seekerSeekCb(self, seeker, position, format):
         try:
@@ -408,7 +411,11 @@ class PitiviViewer(gtk.VBox, Loggable):
         self.seekRelative(gst.SECOND)
 
     def _forwardCb(self, unused_button):
-        self.seek(self.pipeline.getDuration() - 1)
+        try:
+            dur = self.pipeline.getDuration()
+            self.seek(dur - 1)
+        except:
+            self.warning("couldn't get duration")
 
     ## public methods for controlling playback
 
@@ -424,7 +431,10 @@ class PitiviViewer(gtk.VBox, Loggable):
         self.pipeline.togglePlayback()
 
     def seekRelative(self, time):
-        self.pipeline.seekRelative(time)
+        try:
+            self.pipeline.seekRelative(time)
+        except:
+            self.warning("seek failed")
 
     def _posCb(self, unused_pipeline, pos):
         self._newTime(pos)



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