Skip to content

Commit

Permalink
reafluent: Outline unwanted lifetime scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Nov 30, 2023
1 parent 1d6a7ae commit 485c574
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions extension/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ impl HookCommand for HelgoboxExtension {
}

fn add_and_show_playtime() -> Result<()> {
// Unwanted scenario
let current_project = Reaper::get().current_project();
let mut project = current_project.resolve().context("project doesn't exist")?;
let track = project
.tracks()
.next()
.context("project doesn't have tracks")?;
project.delete_track(track);
track.guid();

let instance_id = Reaper::get()
.insert_track_at(0, TrackDefaultsBehavior::OmitDefaultEnvAndFx)
.normal_fx_chain()
Expand Down
2 changes: 1 addition & 1 deletion reafluent/src/fx_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl FxChainDesc {

impl<'a> FxChain<'a> {
pub fn add_fx_by_name<'b>(
&self,
&mut self,
name: impl Into<ReaperStringArg<'b>>,
behavior: AddFxBehavior,
) -> Result<FxDesc, ReaperFunctionError> {
Expand Down
6 changes: 6 additions & 0 deletions reafluent/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ impl<'a> Project<'a> {
self.raw
}

pub fn delete_track(&mut self, track: Track) {
unsafe {
Reaper::get().medium_reaper().delete_track(track.raw());
}
}

pub fn tracks(
&self,
) -> impl Iterator<Item = Track<'a>> + ExactSizeIterator + FusedIterator + DoubleEndedIterator + '_
Expand Down

0 comments on commit 485c574

Please sign in to comment.