diff --git a/Tracks Properties/cfillion_Select destination tracks of selected tracks sends recursively.lua b/Tracks Properties/cfillion_Select destination tracks of selected tracks sends recursively.lua index c30f6e1a0..adca5b64a 100644 --- a/Tracks Properties/cfillion_Select destination tracks of selected tracks sends recursively.lua +++ b/Tracks Properties/cfillion_Select destination tracks of selected tracks sends recursively.lua @@ -1,15 +1,10 @@ -- @description Select destination tracks of selected tracks sends recursively --- @version 1.2 -- @author cfillion --- @changelog --- Fix a bug causing some tracks to not be selected in a single shot --- Ignore muted sends --- Select tracks up the folder hierarchy (obeying parent send) +-- @version 1.2.1 +-- @changelog Fix crash when encountering feedback routings +-- @provides [main] . > cfillion_Select destination tracks of selected tracks sends recursively (background).lua -- @link Forum thread https://forum.cockos.com/showthread.php?t=183638 -- @donation https://www.paypal.me/cfillion --- @provides --- [main] . --- [main] . > cfillion_Select destination tracks of selected tracks sends recursively (background).lua -- This file is also used by cfillion_Select source tracks of selected tracks sends recursively.lua @@ -19,9 +14,9 @@ local destination = scriptName:match("destination") local selected = {} -local function wasSelected(match) - for i,track in ipairs(selected) do - if track == match then +local function inArray(haystack, match) + for i,item in ipairs(haystack) do + if item == match then return true end end @@ -70,12 +65,16 @@ local function enumDirectChildTracks(track) end end -local function highlight(track, select) +local function highlight(track, select, seenTracks) + if not seenTracks then seenTracks = {} end + if inArray(seenTracks, track) then return end + table.insert(seenTracks, track) + for target in enumSendTracks(track) do reaper.SetTrackSelected(target, select) if select then - highlight(target, select) + highlight(target, select, seenTracks) end end @@ -84,12 +83,12 @@ local function highlight(track, select) local parent = parentSend and reaper.GetParentTrack(track) if parent then reaper.SetTrackSelected(parent, select) - highlight(parent, select) + highlight(parent, select, seenTracks) end else for child in enumDirectChildTracks(track) do reaper.SetTrackSelected(child, select) - highlight(child, select) + highlight(child, select, seenTracks) end end end @@ -98,7 +97,7 @@ local function main() for i=0,reaper.CountSelectedTracks(0)-1 do local track = reaper.GetSelectedTrack(0, i) - if not wasSelected(track) then + if not inArray(selected, track) then table.insert(selected, track) end end