[meld/meld-1.6] Check validity of tree cursor path (closes rhbz#832969 and rhbz#837133)



commit f2bc3898b7dcab802da2c1f309bf8ef8aa675a22
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Fri Oct 12 17:51:20 2012 +1000

    Check validity of tree cursor path (closes rhbz#832969 and rhbz#837133)

 meld/dirdiff.py |    8 +++++---
 meld/vcview.py  |    8 +++++---
 2 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index fd6a9fb..e2dc7b1 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -718,15 +718,17 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
         if not cursor_path:
             self.emit("next-diff-changed", False, False)
         else:
-            if self.current_path:
+            try:
                 old_cursor = self.model.get_iter(self.current_path)
+            except (ValueError, TypeError):
+                # An invalid path gives ValueError; None gives a TypeError
+                skip = False
+            else:
                 state = self.model.get_state(old_cursor, 0)
                 # We can skip recalculation if the new cursor is between the
                 # previous/next bounds, and we weren't on a changed row
                 skip = state in (tree.STATE_NORMAL, tree.STATE_EMPTY) and \
                        self.prev_path < cursor_path < self.next_path
-            else:
-                skip = False
 
             if not skip:
                 prev, next = self.model._find_next_prev_diff(cursor_path)
diff --git a/meld/vcview.py b/meld/vcview.py
index 98bc08b..8caf17c 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -699,15 +699,17 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         if not cursor_path:
             self.emit("next-diff-changed", False, False)
         else:
-            if self.current_path:
+            try:
                 old_cursor = self.model.get_iter(self.current_path)
+            except (ValueError, TypeError):
+                # An invalid path gives ValueError; None gives a TypeError
+                skip = False
+            else:
                 state = self.model.get_state(old_cursor, 0)
                 # We can skip recalculation if the new cursor is between the
                 # previous/next bounds, and we weren't on a changed row
                 skip = state in (tree.STATE_NORMAL, tree.STATE_EMPTY) and \
                        self.prev_path < cursor_path < self.next_path
-            else:
-                skip = False
 
             if not skip:
                 prev, next = self.model._find_next_prev_diff(cursor_path)



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