Keep Playlist._loaded up to date on Curve.unload() calls.
authorW. Trevor King <wking@drexel.edu>
Fri, 27 Aug 2010 20:14:25 +0000 (16:14 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 27 Aug 2010 20:14:25 +0000 (16:14 -0400)
hooke/playlist.py
hooke/plugin/playlist.py

index 63d1843..69442da 100644 (file)
@@ -160,14 +160,13 @@ class Playlist (NoteIndexList):
     def __init__(self, drivers, name=None):
         super(Playlist, self).__init__(name=name)
         self.drivers = drivers
-        self._max_loaded = 100 # curves to hold in memory simultaneously.
 
     def _set_default_attrs(self):
         super(Playlist, self)._set_default_attrs()
         self._default_attrs['drivers'] = []
         # List of loaded curves, see :meth:`._setup_item`.
         self._default_attrs['_loaded'] = []
-        self._default_attrs['_max_loaded'] = 100
+        self._default_attrs['_max_loaded'] = 100  # curves to hold in memory simultaneously.
 
     def __setstate__(self, state):
         super(Playlist, self).__setstate__(state)
@@ -201,6 +200,12 @@ class Playlist (NoteIndexList):
                 oldest = self._loaded.pop(0)
                 oldest.unload()
 
+    def unload(self, curve):
+        "Inverse of .`_setup_item`."
+        curve.unload()
+        self._loaded.remove(curve)
+
+
 def playlist_path(path):
     """Normalize playlist path extensions.
 
index ed904c6..43978b5 100644 (file)
@@ -385,7 +385,7 @@ Evaluate the applied command stack immediately.
                 for command in params['commands']:
                     curve.command_stack.append(command)
                 curve.set_hooke(hooke)
-                curve.unload()
+                p.unload(curve)
 
     def __setup_params(self, hooke, params):
         if params['commands'] == None: