From cf4346a398bd5107aca7c1d5b6e99d81bb4a1d9e Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 11 Nov 2010 08:13:09 -0500 Subject: [PATCH] Only shallow copy when filtering a playlist. We should iterate through the base playlist, because iterating over a playlist that's having items removed is poorly defined. However, if were iterating through the input playlist and removing items from the copy, we need a shallow copy so the item ids still match. Curves can belong to several playlists, so shallow copies are ok. Another problem with the old version was that the _index was being updated in the copy, not the current curve, so the current_curve_callback() bit was *not* working. --- hooke/playlist.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hooke/playlist.py b/hooke/playlist.py index cd5f9fb..6dde157 100644 --- a/hooke/playlist.py +++ b/hooke/playlist.py @@ -138,11 +138,11 @@ class NoteIndexList (list): def filter(self, keeper_fn=lambda item:True, load_curves=True, *args, **kwargs): - c = copy.deepcopy(self) + c = copy.copy(self) if load_curves == True: - items = c.items(reverse=True) + items = self.items(reverse=True) else: - items = reversed(c) + items = reversed(self) for item in items: if keeper_fn(item, *args, **kwargs) != True: c.remove(item) -- 2.26.2