refactor: add function annotation and check return value
Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
This commit is contained in:
parent
6a39d65a5b
commit
b3593bd713
|
@ -9,7 +9,9 @@ ardour {
|
||||||
function factory()
|
function factory()
|
||||||
-- there is currently no direct way to find the track
|
-- there is currently no direct way to find the track
|
||||||
-- corresponding to a [selected] region
|
-- corresponding to a [selected] region
|
||||||
function find_track_for_region(region_id)
|
---@param region_id ID
|
||||||
|
---@return Track?
|
||||||
|
local function find_track_for_region(region_id)
|
||||||
for route in Session:get_tracks():iter() do
|
for route in Session:get_tracks():iter() do
|
||||||
local track = route:to_track()
|
local track = route:to_track()
|
||||||
local pl = track:playlist()
|
local pl = track:playlist()
|
||||||
|
@ -30,8 +32,7 @@ function factory()
|
||||||
-- for each selected region...
|
-- for each selected region...
|
||||||
for region in sel.regions:regionlist():iter() do
|
for region in sel.regions:regionlist():iter() do
|
||||||
-- test if it's an audio region
|
-- test if it's an audio region
|
||||||
local ar = region:to_audioregion()
|
if region:to_audioregion():isnil() then
|
||||||
if ar:isnil() then
|
|
||||||
goto next
|
goto next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,6 +49,7 @@ function factory()
|
||||||
|
|
||||||
local track = find_track_for_region(rid)
|
local track = find_track_for_region(rid)
|
||||||
|
|
||||||
|
if track then
|
||||||
region:to_stateful():clear_changes()
|
region:to_stateful():clear_changes()
|
||||||
|
|
||||||
--~ print("Marker label:", mloc:name())
|
--~ print("Marker label:", mloc:name())
|
||||||
|
@ -56,6 +58,7 @@ function factory()
|
||||||
|
|
||||||
-- collect undo data
|
-- collect undo data
|
||||||
Session:add_stateful_diff_command(region:to_statefuldestructible())
|
Session:add_stateful_diff_command(region:to_statefuldestructible())
|
||||||
|
end
|
||||||
|
|
||||||
::next::
|
::next::
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue