[vlmc-devel] commit: Don't add a Clip twice. (Hugo Beauzee-Luyssen )

git at videolan.org git at videolan.org
Tue Apr 13 14:38:07 CEST 2010


vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Tue Apr 13 12:56:18 2010 +0200| [acf5311149193f044ccd93b113bd8be02f7eff60] | committer: Hugo Beauzee-Luyssen 

Don't add a Clip twice.

The forest boolean is back !

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

 src/Commands/Commands.cpp     |   11 +++++++----
 src/Commands/Commands.h       |    3 ++-
 src/Workflow/MainWorkflow.cpp |   10 ++++++----
 src/Workflow/MainWorkflow.h   |    4 +++-
 4 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index f504d41..e6d23cf 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -44,11 +44,13 @@ void Commands::trigger( Commands::Generic* command )
 
 Commands::MainWorkflow::AddClip::AddClip( Clip* clip,
                                           unsigned int trackNumber, qint64 pos,
-                                          ::MainWorkflow::TrackType trackType ) :
+                                          ::MainWorkflow::TrackType trackType,
+                                          bool undoRedoAction /*= false*/ ) :
         m_clip( clip ),
         m_trackNumber( trackNumber ),
         m_pos( pos ),
-        m_trackType( trackType )
+        m_trackType( trackType ),
+        m_undoRedoAction( undoRedoAction )
 {
     setText( QObject::tr( "Adding clip to track %1" ).arg( QString::number( trackNumber ) ) );
 }
@@ -59,7 +61,8 @@ Commands::MainWorkflow::AddClip::~AddClip()
 
 void Commands::MainWorkflow::AddClip::redo()
 {
-    m_uuid = ::MainWorkflow::getInstance()->addClip( m_clip, m_trackNumber, m_pos, m_trackType );
+    m_uuid = ::MainWorkflow::getInstance()->addClip( m_clip, m_trackNumber, m_pos, m_trackType, m_undoRedoAction );
+    m_undoRedoAction = false;
 }
 
 void Commands::MainWorkflow::AddClip::undo()
@@ -116,7 +119,7 @@ void Commands::MainWorkflow::RemoveClip::redo()
 }
 void Commands::MainWorkflow::RemoveClip::undo()
 {
-    ::MainWorkflow::getInstance()->addClip( m_clip, m_trackNumber, m_pos, m_trackType );
+    ::MainWorkflow::getInstance()->addClip( m_clip, m_trackNumber, m_pos, m_trackType, true );
 }
 
 Commands::MainWorkflow::ResizeClip::ResizeClip( const QUuid& uuid,
diff --git a/src/Commands/Commands.h b/src/Commands/Commands.h
index 9aa5305..75d6483 100644
--- a/src/Commands/Commands.h
+++ b/src/Commands/Commands.h
@@ -62,7 +62,7 @@ namespace Commands
         {
             public:
                 AddClip( Clip* clip, unsigned int trackNumber, qint64 pos,
-                         ::MainWorkflow::TrackType trackType );
+                         ::MainWorkflow::TrackType trackType, bool undoRedoAction = false );
                 virtual ~AddClip();
                 virtual void    redo();
                 virtual void    undo();
@@ -73,6 +73,7 @@ namespace Commands
                 qint64                      m_pos;
                 ::MainWorkflow::TrackType   m_trackType;
                 QUuid                       m_uuid;
+                bool                        m_undoRedoAction;
         };
 
         NEW_COMMAND( MoveClip )
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index d9c6837..bd72407 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -74,12 +74,14 @@ MainWorkflow::~MainWorkflow()
 
 const QUuid&
 MainWorkflow::addClip( Clip *clip, unsigned int trackId,
-                                        qint64 start, MainWorkflow::TrackType trackType )
+                                        qint64 start, MainWorkflow::TrackType trackType,
+                                        bool informGui )
 {
     const QUuid&    uuid = m_tracks[trackType]->addClip( clip, trackId, start );
     computeLength();
     //Inform the GUI
-    emit clipAdded( clip, trackId, start, trackType );
+    if ( informGui == true )
+        emit clipAdded( clip, trackId, start, trackType );
     return uuid;
 }
 
@@ -325,7 +327,7 @@ MainWorkflow::loadProject( const QDomElement &root )
             if ( c != NULL )
             {
                 addClip( new Clip( c, begin.toLongLong(), end.toLongLong() ),
-                         trackId, startFrame.toLongLong(), type );
+                         trackId, startFrame.toLongLong(), type, true );
             }
             clip = clip.nextSibling().toElement();
         }
@@ -416,7 +418,7 @@ MainWorkflow::split( Clip* toSplit, Clip* newClip, quint32 trackId, qint64 newCl
         newClip = new Clip( toSplit, newClipBegin, toSplit->end() );
 
     toSplit->setEnd( newClipBegin, true );
-    addClip( newClip, trackId, newClipPos, trackType );
+    addClip( newClip, trackId, newClipPos, trackType, true );
     return newClip;
 }
 
diff --git a/src/Workflow/MainWorkflow.h b/src/Workflow/MainWorkflow.h
index 2acbd94..54b7cd7 100644
--- a/src/Workflow/MainWorkflow.h
+++ b/src/Workflow/MainWorkflow.h
@@ -97,12 +97,14 @@ class   MainWorkflow : public QObject, public Singleton<MainWorkflow>
          *  \param      trackId The number of the track (starting at 0)
          *  \param      start   The clip's starting position
          *  \param      type    The track type (audio or video)
+         *  \param      informGui  Will be false if the action is queried by the GUI.
+         *                              true otherwise.
          *  \sa         removeClip( const QUuid&, unsigned int, MainWorkflow::TrackType )
          *  \sa         clipAdded( Clip*, unsigned int, qint64, MainWorkflow::TrackType )
          *  \return     The newly inserted ClipWorkflow's UUID.
          */
         const QUuid&            addClip( Clip* clip, unsigned int trackId, qint64 start,
-                                         TrackType type );
+                                         TrackType type, bool informGui );
 
         /**
          *  \brief      Initialize the workflow for the render.



More information about the Vlmc-devel mailing list