Skip to content

Commit

Permalink
Release Select destination tracks of selected tracks sends recursivel…
Browse files Browse the repository at this point in the history
…y v1.2.1 (ReaTeam#187)

Fix crash when encountering feedback routings
  • Loading branch information
cfillion authored May 19, 2019
1 parent 497b177 commit 4305c75
Showing 1 changed file with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4305c75

Please sign in to comment.