[vlmc-devel] Commands::Clip::Resize : Take a shared_ptr instead of a raw pointer

Yikai Lu git at videolan.org
Tue Jun 28 10:39:49 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Tue Jun 28 17:24:37 2016 +0900| [f059259c4105bc0285872bcddb9e85d390489eca] | committer: Yikai Lu

Commands::Clip::Resize : Take a shared_ptr instead of a raw pointer

> https://code.videolan.org/videolan/vlmc/commit/f059259c4105bc0285872bcddb9e85d390489eca
---

 src/Commands/Commands.cpp                      | 4 ++--
 src/Commands/Commands.h                        | 4 ++--
 src/Gui/timeline/AbstractGraphicsMediaItem.cpp | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index d25ca93..4e83914 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -199,7 +199,7 @@ Commands::Clip::Remove::internalUndo()
     m_trackWorkflow->addClip( m_clip, m_pos );
 }
 
-Commands::Clip::Resize::Resize( TrackWorkflow* tw, ::Clip* clip, qint64 newBegin,
+Commands::Clip::Resize::Resize( TrackWorkflow* tw, std::shared_ptr<::Clip> const& clip, qint64 newBegin,
                                 qint64 newEnd, qint64 newPos ) :
     m_trackWorkflow( tw ),
     m_clip( clip ),
@@ -207,7 +207,7 @@ Commands::Clip::Resize::Resize( TrackWorkflow* tw, ::Clip* clip, qint64 newBegin
     m_newEnd( newEnd ),
     m_newPos( newPos )
 {
-    connect( clip, &::Clip::destroyed, this, &Resize::invalidate );
+    connect( clip.get(), &::Clip::destroyed, this, &Resize::invalidate );
     m_oldBegin = clip->begin();
     m_oldEnd = clip->end();
     m_oldPos = tw->getClipPosition( clip->uuid() );
diff --git a/src/Commands/Commands.h b/src/Commands/Commands.h
index 551b040..ffe4e1d 100644
--- a/src/Commands/Commands.h
+++ b/src/Commands/Commands.h
@@ -141,7 +141,7 @@ namespace Commands
             Q_OBJECT
 
             public:
-                Resize( TrackWorkflow* tw, ::Clip* clip,
+                Resize( TrackWorkflow* tw, std::shared_ptr<::Clip> const& clip,
                             qint64 newBegin, qint64 newEnd, qint64 newPos );
                 virtual void    internalRedo();
                 virtual void    internalUndo();
@@ -149,7 +149,7 @@ namespace Commands
 
             private:
                 TrackWorkflow*              m_trackWorkflow;
-                ::Clip*                     m_clip;
+                std::shared_ptr<::Clip>     m_clip;
                 qint64                      m_newBegin;
                 qint64                      m_newEnd;
                 qint64                      m_oldBegin;
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
index ae8fa54..4198faa 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
@@ -265,7 +265,7 @@ AbstractGraphicsMediaItem::triggerResize( TrackWorkflow* target,
 {
     if ( target == nullptr )
         return ;
-    Commands::trigger( new Commands::Clip::Resize( target, m_clip.get(), newBegin,
+    Commands::trigger( new Commands::Clip::Resize( target, m_clip, newBegin,
                                                                newEnd, pos ) );
     emit lengthChanged( newEnd - newBegin + 1 );
 }



More information about the Vlmc-devel mailing list