Clear NoteIndexList in .__setstate__ to avoid doubling items during engine->UI passing.
authorW. Trevor King <wking@drexel.edu>
Sat, 21 Aug 2010 19:05:41 +0000 (15:05 -0400)
committerW. Trevor King <wking@drexel.edu>
Sat, 21 Aug 2010 19:05:41 +0000 (15:05 -0400)
hooke/playlist.py

index 3380bfcacfc4ca24a02f4ee49e11c89370fa9cd0..6e8f232c9da0482310408f6fede249c7b8578016 100644 (file)
@@ -82,6 +82,7 @@ class NoteIndexList (list):
 
     def __setstate__(self, state):
         self._set_ignored_attrs()
+        self.clear()
         for key,value in self._default_attrs.items():
             setattr(self, key, value)
         for key,value in state.items():
@@ -113,6 +114,10 @@ class NoteIndexList (list):
         """
         pass
 
+    def clear(self):
+        while len(self) > 0:
+            self.pop()
+
     def index(self, value=None, *args, **kwargs):
         """Extend `list.index`, returning the current index if `value`
         is `None`.