[vlmc-devel] commit: TrackWorkflow: Watch for ClipHelper deletion ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Thu Oct 7 15:03:01 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Oct  7 13:05:29 2010 +0200| [69d954dbd104ebd463cda3fff82c0a4dba063b1f] | committer: Hugo Beauzée-Luyssen 

TrackWorkflow: Watch for ClipHelper deletion

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=69d954dbd104ebd463cda3fff82c0a4dba063b1f
---

 src/Workflow/TrackWorkflow.cpp |   30 ++++++++++++++++++++++++++++++
 src/Workflow/TrackWorkflow.h   |    1 +
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index 88550a5..b3c7730 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -103,6 +103,8 @@ TrackWorkflow::addClip( ClipWorkflow* cw, qint64 start )
              this, SLOT( __effectMoved( EffectHelper*, qint64) ) );
     connect( cw, SIGNAL( effectRemoved( QUuid ) ),
              this, SLOT( __effectRemoved( QUuid ) ) );
+    connect( cw->getClipHelper(), SIGNAL( destroyed( QUuid ) ),
+             this, SLOT( clipDestroyed( QUuid ) ) );
     emit clipAdded( this, cw->getClipHelper(), start );
     computeLength();
 }
@@ -397,6 +399,32 @@ void            TrackWorkflow::moveClip( const QUuid& id, qint64 startingFrame )
     }
 }
 
+void
+TrackWorkflow::clipDestroyed( const QUuid& id )
+{
+    QWriteLocker    lock( m_clipsLock );
+
+    QMap<qint64, ClipWorkflow*>::iterator       it = m_clips.begin();
+    QMap<qint64, ClipWorkflow*>::iterator       end = m_clips.end();
+
+    while ( it != end )
+    {
+        if ( it.value()->getClipHelper()->uuid() == id )
+        {
+            ClipWorkflow*   cw = it.value();
+            m_clips.erase( it );
+            stopClipWorkflow( cw );
+            computeLength();
+            cw->disconnect();
+            cw->getClipHelper()->disconnect( this );
+            emit clipRemoved( this, cw->getClipHelper()->uuid() );
+            cw->deleteLater();
+            return ;
+        }
+        ++it;
+    }
+}
+
 Clip*       TrackWorkflow::removeClip( const QUuid& id )
 {
     QWriteLocker    lock( m_clipsLock );
@@ -414,6 +442,7 @@ Clip*       TrackWorkflow::removeClip( const QUuid& id )
             stopClipWorkflow( cw );
             computeLength();
             cw->disconnect();
+            cw->getClipHelper()->disconnect( this );
             emit clipRemoved( this, cw->getClipHelper()->uuid() );
             cw->deleteLater();
             return clip;
@@ -438,6 +467,7 @@ ClipWorkflow*       TrackWorkflow::removeClipWorkflow( const QUuid& id )
             cw->disconnect();
             m_clips.erase( it );
             computeLength();
+            cw->getClipHelper()->disconnect( this );
             emit clipRemoved( this, cw->getClipHelper()->uuid() );
             return cw;
         }
diff --git a/src/Workflow/TrackWorkflow.h b/src/Workflow/TrackWorkflow.h
index 1012895..45fe669 100644
--- a/src/Workflow/TrackWorkflow.h
+++ b/src/Workflow/TrackWorkflow.h
@@ -136,6 +136,7 @@ class   TrackWorkflow : public EffectUser
         void                __effectAdded( EffectHelper*, qint64 );
         void                __effectRemoved( const QUuid& );
         void                __effectMoved( EffectHelper*, qint64 );
+        void                clipDestroyed( const QUuid &uuid );
 
     signals:
         void                lengthChanged( qint64 newLength );



More information about the Vlmc-devel mailing list