mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
delete autoremoved clips from pool
This commit is contained in:
parent
a9cfaf9767
commit
7af98b7008
2 changed files with 15 additions and 3 deletions
|
|
@ -210,14 +210,18 @@ impl Tek {
|
||||||
|
|
||||||
// Remove clip from arrangement when exiting empty clip editor
|
// Remove clip from arrangement when exiting empty clip editor
|
||||||
pub fn clip_auto_remove (&mut self) {
|
pub fn clip_auto_remove (&mut self) {
|
||||||
if let Some(ref pool) = self.pool
|
if let Some(ref mut pool) = self.pool
|
||||||
&& let Selection::Clip(t, s) = self.selected
|
&& let Selection::Clip(t, s) = self.selected
|
||||||
&& let Some(scene) = self.scenes.get_mut(s)
|
&& let Some(scene) = self.scenes.get_mut(s)
|
||||||
&& let Some(slot) = scene.clips.get_mut(t)
|
&& let Some(slot) = scene.clips.get_mut(t)
|
||||||
&& let Some(clip) = slot
|
&& let Some(clip) = slot.as_mut()
|
||||||
{
|
{
|
||||||
|
let mut swapped = None;
|
||||||
if clip.read().unwrap().count_midi_messages() == 0 {
|
if clip.read().unwrap().count_midi_messages() == 0 {
|
||||||
*slot = None;
|
std::mem::swap(&mut swapped, slot);
|
||||||
|
}
|
||||||
|
if let Some(clip) = swapped {
|
||||||
|
pool.delete_clip(&clip.read().unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,4 +103,12 @@ impl MidiPool {
|
||||||
self.clip.store(index, Relaxed);
|
self.clip.store(index, Relaxed);
|
||||||
(index, clip)
|
(index, clip)
|
||||||
}
|
}
|
||||||
|
pub fn delete_clip (&mut self, clip: &MidiClip) -> bool {
|
||||||
|
let index = self.clips.read().unwrap().iter().position(|x|*x.read().unwrap()==*clip);
|
||||||
|
if let Some(index) = index {
|
||||||
|
self.clips.write().unwrap().remove(index);
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue