From 9b381902113fcc3b384bb83503028c21a9f01e2f Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sun, 25 May 2008 14:11:28 -0500 Subject: [PATCH] Add locking. Don't call handle_widget_change often while dragging. --- Timeline/Sequence.C | 20 ++++++++++++++------ Timeline/Sequence_Widget.C | 9 +++++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Timeline/Sequence.C b/Timeline/Sequence.C index c902838..28979e1 100644 --- a/Timeline/Sequence.C +++ b/Timeline/Sequence.C @@ -124,12 +124,12 @@ Sequence::draw ( void ) fl_clip_box( x(), y(), w(), h(), X, Y, W, H ); - if ( Sequence_Widget::pushed() && Sequence_Widget::pushed()->sequence() == this ) - { - /* make sure the Sequence_Widget::pushed widget is above all others */ - remove( Sequence_Widget::pushed() ); - add( Sequence_Widget::pushed() ); - } +/* if ( Sequence_Widget::pushed() && Sequence_Widget::pushed()->sequence() == this ) */ +/* { */ +/* /\* make sure the Sequence_Widget::pushed widget is above all others *\/ */ +/* remove( Sequence_Widget::pushed() ); */ +/* add( Sequence_Widget::pushed() ); */ +/* } */ // printf( "track::draw %d,%d %dx%d\n", X,Y,W,H ); @@ -149,8 +149,12 @@ Sequence::draw ( void ) void Sequence::remove ( Sequence_Widget *r ) { + timeline->wrlock(); + _widgets.remove( r ); + timeline->unlock(); + handle_widget_change( r->start(), r->length() ); } @@ -209,11 +213,15 @@ Sequence::add ( Sequence_Widget *r ) // r->track()->redraw(); } + timeline->wrlock(); + r->sequence( this ); _widgets.push_back( r ); sort(); + timeline->unlock(); + handle_widget_change( r->start(), r->length() ); } diff --git a/Timeline/Sequence_Widget.C b/Timeline/Sequence_Widget.C index b6d2fc8..a7a2fb7 100644 --- a/Timeline/Sequence_Widget.C +++ b/Timeline/Sequence_Widget.C @@ -88,7 +88,12 @@ void Sequence_Widget::begin_drag ( const Drag &d ) { _drag = new Drag( d ); + + timeline->rdlock(); + _r = new Range( _range ); + + timeline->unlock(); } void @@ -106,6 +111,8 @@ Sequence_Widget::end_drag ( void ) delete _drag; _drag = NULL; + + sequence()->handle_widget_change( _r->start, _r->length ); } /** set position of widget on the timeline. */ @@ -313,8 +320,6 @@ Sequence_Widget::handle ( int m ) _log.release(); } - sequence()->handle_widget_change( _r->start, _r->length ); - fl_cursor( FL_CURSOR_HAND ); return 1;