From b20156053e024b5bcb1affb5e9f281eff2545cd8 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sun, 25 May 2008 23:08:25 -0500 Subject: [PATCH] Add appropriate locking. Make control sequences removable. --- Timeline/Control_Sequence.C | 8 +++++--- Timeline/Timeline.C | 11 +++++++++-- Timeline/Track.C | 12 ++++++++++++ Timeline/Track.H | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Timeline/Control_Sequence.C b/Timeline/Control_Sequence.C index ea71c7e..52e28fe 100644 --- a/Timeline/Control_Sequence.C +++ b/Timeline/Control_Sequence.C @@ -37,11 +37,11 @@ Control_Sequence::Control_Sequence ( Track *track ) : Sequence( 0 ) _track = track; + _output = new Port( Port::Output, track->name(), track->ncontrols(), "cv" ); + if ( track ) track->add( this ); - _output = new Port( Port::Output, track->name(), track->ncontrols(), "cv" ); - log_create(); } @@ -50,6 +50,8 @@ Control_Sequence::~Control_Sequence ( ) { log_destroy(); + _output->shutdown(); + delete _output; } @@ -306,7 +308,7 @@ Control_Sequence::handle ( int m ) } else if ( r == &menu[ 1 ] ) { - /* TODO: remove */ + Fl::delete_widget( this ); } } diff --git a/Timeline/Timeline.C b/Timeline/Timeline.C index 9b39ab0..8b0bd68 100644 --- a/Timeline/Timeline.C +++ b/Timeline/Timeline.C @@ -39,6 +39,8 @@ #include "Track.H" #include "Transport.H" +#include "Engine/Engine.H" // for lock() + bool Timeline::draw_with_measure_lines = true; @@ -1165,9 +1167,12 @@ Timeline::add_track ( Track *track ) { DMESSAGE( "added new track to the timeline" ); - /* FIXME: do locking */ + engine->lock(); + tracks->add( track ); + engine->unlock(); + /* FIXME: why is this necessary? doesn't the above add do DAMAGE_CHILD? */ redraw(); @@ -1178,11 +1183,13 @@ Timeline::remove_track ( Track *track ) { DMESSAGE( "removed track from the timeline" ); - /* FIXME: do locking */ + engine->lock(); /* FIXME: what to do about track contents? */ tracks->remove( track ); + engine->unlock(); + /* FIXME: why is this necessary? doesn't the above add do DAMAGE_CHILD? */ redraw(); } diff --git a/Timeline/Track.C b/Timeline/Track.C index 7e5e234..332ce0d 100644 --- a/Timeline/Track.C +++ b/Timeline/Track.C @@ -29,6 +29,8 @@ // #include #include +#include "Engine/Engine.H" // for lock() + #include "Control_Sequence.H" #include "Annotation_Sequence.H" @@ -362,9 +364,15 @@ Track::remove ( Audio_Sequence *t ) void Track::remove ( Control_Sequence *t ) { + engine->lock(); + control->remove( t ); + engine->unlock(); + resize(); + + redraw(); } void @@ -388,10 +396,14 @@ Track::add ( Control_Sequence *t ) { DMESSAGE( "adding control sequence" ); + engine->lock(); + t->track( this ); control->add( t ); + engine->unlock(); + resize(); } diff --git a/Timeline/Track.H b/Timeline/Track.H index 8f2397d..a08e938 100644 --- a/Timeline/Track.H +++ b/Timeline/Track.H @@ -215,7 +215,7 @@ public: int size ( void ) const { return _size; } - int ncontrols ( void ) { return controls->children(); } + int ncontrols ( void ) { return control->children(); } void resize ( void ); void size ( int v );