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 63d1843273f31fe6ec43034fea65a5a70c5e7324..69442da74fa63033980b942431ca04a3a8b84ae5 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 ed904c640839dab6c78394c252839727a08768b6..43978b5669f7eba4f58fbb43241fa2dbb6090309 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: