From 27ab4c54840481dee149cf8841e780275f015270 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Mon, 2 Aug 2010 14:12:12 +0000 Subject: [PATCH] Raise error if duplicate handle added to model svn: r15680 --- src/gui/views/treemodels/flatbasemodel.py | 3 +++ src/gui/views/treemodels/treebasemodel.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/views/treemodels/flatbasemodel.py b/src/gui/views/treemodels/flatbasemodel.py index 005a294b4..8a1f40a5f 100644 --- a/src/gui/views/treemodels/flatbasemodel.py +++ b/src/gui/views/treemodels/flatbasemodel.py @@ -303,6 +303,9 @@ class FlatNodeMap(object): :Returns: path of the row inserted in the treeview :Returns type: integer or None """ + if srtkey_hndl[1] in self._hndl2index: + raise ValueError, 'Attempt to add row twice to the model (%s)' % \ + srtkey_hndl[1] if not self._identical: bisect.insort_left(self._fullhndl, srtkey_hndl) if allkeyonly: diff --git a/src/gui/views/treemodels/treebasemodel.py b/src/gui/views/treemodels/treebasemodel.py index c077cb1e3..bb3377c3c 100644 --- a/src/gui/views/treemodels/treebasemodel.py +++ b/src/gui/views/treemodels/treebasemodel.py @@ -590,8 +590,8 @@ class TreeBaseModel(gtk.GenericTreeModel): Otherwise, a node should never be added twice! """ if not self.group_can_have_handle: - raise ValueError, 'attempt to add twice a node to the model %s' % \ - str(parent) + ' ' + str(child) + ' ' + sortkey + raise ValueError, 'Attempt to add node twice to the model (%s:%s)' \ + % (str(parent), str(child)) if handle: node.set_handle(handle) if not self._in_build: