From 39dffab5d36a997cc76ad9069fe00de51d3147a0 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 27 Aug 2010 18:44:01 -0400 Subject: [PATCH] Don't load curves becore clearing their command stack. Loading a curve (which would happen if it had been unloaded before being summoned by current_curve_callback) executes its command stack. Since 'clear curve command stack' is only trying to remove the stack, that stack execution is a waste of time. With the unloaded callback, we can remove the command stack without ever loading the curve. --- hooke/playlist.py | 5 +++-- hooke/plugin/curve.py | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/hooke/playlist.py b/hooke/playlist.py index 80d60fb..79f785c 100644 --- a/hooke/playlist.py +++ b/hooke/playlist.py @@ -91,11 +91,12 @@ class NoteIndexList (list): return self._index return super(NoteIndexList, self).index(value, *args, **kwargs) - def current(self): + def current(self, load=True): if len(self) == 0: return None item = self[self._index] - self._setup_item(item) + if load == True: + self._setup_item(item) return item def jump(self, index): diff --git a/hooke/plugin/curve.py b/hooke/plugin/curve.py index 931dca3..d51ddfd 100644 --- a/hooke/plugin/curve.py +++ b/hooke/plugin/curve.py @@ -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) -- 2.26.2