Don't load curves becore clearing their command stack.
[hooke.git] / hooke / plugin / curve.py
index 931dca3e69ef6e033da4d034ea28467c32263ec2..d51ddfdef1681851bb0e4fbcaffb688054af4699 100644 (file)
@@ -41,15 +41,20 @@ from .playlist import current_playlist_callback
 
 # Define common or complicated arguments
 
-def current_curve_callback(hooke, command, argument, value):
+def current_curve_callback(hooke, command, argument, value, load=True):
     if value != None:
         return value
     playlist = current_playlist_callback(hooke, command, argument, value)
-    curve = playlist.current()
+    curve = playlist.current(load=load)
     if curve == None:
         raise Failure('No curves in %s' % playlist)
     return curve
 
+def unloaded_current_curve_callback(hooke, command, argument, value):
+    return current_curve_callback(
+        hooke=hooke, command=command, argument=argument, value=value,
+        load=False)
+
 CurveArgument = Argument(
     name='curve', type='curve', callback=current_curve_callback,
     help="""
@@ -634,6 +639,11 @@ class ClearStackCommand (CurveCommand):
         super(ClearStackCommand, self).__init__(
             name='clear curve command stack',
             help=self.__doc__, plugin=plugin)
+        i,arg = [(i,arg) for i,arg in enumerate(self.arguments)
+                 if arg.name == 'curve'][0]
+        arg = copy.copy(arg)
+        arg.callback = unloaded_current_curve_callback
+        self.arguments[i] = arg
 
     def _run(self, hooke, inqueue, outqueue, params):
         curve = self._curve(hooke, params)