[vlmc-devel] commit: ClipRenderer: Unload previous clip when selecting a new one. ( Hugo Beauzee-Luyssen )

git at videolan.org git at videolan.org
Tue Mar 16 23:34:40 CET 2010


vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Tue Mar 16 23:33:17 2010 +0100| [b9cfe43189d01574c9634a8c35ca9f25f0c6c3e5] | committer: Hugo Beauzee-Luyssen 

ClipRenderer: Unload previous clip when selecting a new one.

Consistancy: when a clip is removed, use a QUuid. When another action
occured on a clip, use its pointer.

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

 src/Gui/import/ImportController.cpp |    7 +++----
 src/Gui/library/MediaListView.cpp   |    6 +++---
 src/Gui/library/MediaListView.h     |    2 +-
 src/Library/MediaContainer.cpp      |    6 ------
 src/Library/MediaContainer.h        |    3 +--
 src/Renderer/ClipRenderer.cpp       |   10 ++++------
 src/Renderer/ClipRenderer.h         |    1 -
 7 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/src/Gui/import/ImportController.cpp b/src/Gui/import/ImportController.cpp
index 6a6884d..6cfa004 100644
--- a/src/Gui/import/ImportController.cpp
+++ b/src/Gui/import/ImportController.cpp
@@ -97,8 +97,8 @@ ImportController::ImportController(QWidget *parent) :
              m_clipRenderer, SLOT( setClip( Clip* ) ) );
     connect( m_mediaListView, SIGNAL( clipSelected( Clip* ) ),
              this, SLOT( clipSelection( Clip* ) ) );
-    connect( m_mediaListView, SIGNAL( clipRemoved( const Clip* ) ),
-             m_clipRenderer, SLOT( clipUnloaded( const Clip* ) ) );
+    connect( m_mediaListView, SIGNAL( clipRemoved( const QUuid& ) ),
+             m_clipRenderer, SLOT( clipUnloaded( const QUuid& ) ) );
 
     connect( MetaDataManager::getInstance(), SIGNAL( failedToCompute( Media* ) ),
              this, SLOT( failedToLoad( Media* ) ) );
@@ -132,7 +132,6 @@ ImportController::clipSelection( Clip* clip )
     const QUuid& uuid = clip->uuid();
     if ( m_currentUuid == uuid )
         return ;
-    Media*  media = clip->rootClip()->getMedia();
     setUIMetaData( clip->rootClip() );
     m_preview->stop();
     m_currentUuid = uuid;
@@ -323,7 +322,7 @@ ImportController::failedToLoad( Media *media )
     m_ui->errorLabelImg->show();
     m_ui->errorLabel->show();
     QTimer::singleShot( 3000, this, SLOT( hideErrors() ) );
-    delete m_temporaryMedias->removeClip( media->baseClip() );
+    delete m_temporaryMedias->removeClip( media->baseClip()->uuid() );
     delete media;
 }
 
diff --git a/src/Gui/library/MediaListView.cpp b/src/Gui/library/MediaListView.cpp
index 33b02e8..52cb427 100644
--- a/src/Gui/library/MediaListView.cpp
+++ b/src/Gui/library/MediaListView.cpp
@@ -34,8 +34,8 @@ MediaListView::MediaListView( StackViewController* nav, MediaContainer* mc ) :
 {
     connect( mc, SIGNAL( newClipLoaded(Clip*) ),
              this, SLOT( newClipLoaded( Clip* ) ) );
-    connect( this, SIGNAL( clipRemoved( const Clip* ) ),
-             mc, SLOT( removeClip( const Clip* ) ) );
+    connect( this, SIGNAL( clipRemoved( const QUuid& ) ),
+             mc, SLOT( removeClip( const QUuid& ) ) );
     connect( mc, SIGNAL( clipRemoved( const QUuid& ) ),
              this, SLOT( __clipRemoved( const QUuid& ) ) );
     foreach ( Clip* clip, mc->clips() )
@@ -87,7 +87,7 @@ void    MediaListView::cellSelection( const QUuid& uuid )
 void    MediaListView::removeClip( const Clip* clip )
 {
     __clipRemoved( clip->uuid() );
-    emit clipRemoved( clip );
+    emit clipRemoved( clip->uuid() );
 }
 
 void
diff --git a/src/Gui/library/MediaListView.h b/src/Gui/library/MediaListView.h
index 36e9847..68a9057 100644
--- a/src/Gui/library/MediaListView.h
+++ b/src/Gui/library/MediaListView.h
@@ -69,6 +69,6 @@ private slots:
 
 signals:
     void        clipSelected( Clip* );
-    void        clipRemoved( const Clip* );
+    void        clipRemoved( const QUuid& );
 };
 #endif // MEDIALISTVIEW_H
diff --git a/src/Library/MediaContainer.cpp b/src/Library/MediaContainer.cpp
index a3755cf..cf13f99 100644
--- a/src/Library/MediaContainer.cpp
+++ b/src/Library/MediaContainer.cpp
@@ -163,12 +163,6 @@ MediaContainer::removeClip( const QUuid &uuid )
     return NULL;
 }
 
-Clip*
-MediaContainer::removeClip( const Clip* clip )
-{
-    return removeClip( clip->uuid() );
-}
-
 const QHash<QUuid, Clip*>&
 MediaContainer::clips() const
 {
diff --git a/src/Library/MediaContainer.h b/src/Library/MediaContainer.h
index d146573..e503041 100644
--- a/src/Library/MediaContainer.h
+++ b/src/Library/MediaContainer.h
@@ -132,9 +132,8 @@ protected:
 public slots:
     /**
      *  \brief  Delete a Clip from the container
-     *  \param  clip    The clip to remove.
+     *  \param  uuid    The clip to remove's uuid.
      */
-    Clip    *removeClip( const Clip* clip );
     Clip    *removeClip( const QUuid& uuid );
     /**
      *  \brief  Clear the library (remove all the loaded Clip, delete their subclips, and
diff --git a/src/Renderer/ClipRenderer.cpp b/src/Renderer/ClipRenderer.cpp
index 7e010ff..0c0bc94 100644
--- a/src/Renderer/ClipRenderer.cpp
+++ b/src/Renderer/ClipRenderer.cpp
@@ -59,6 +59,10 @@ ClipRenderer::~ClipRenderer()
 void
 ClipRenderer::setClip( Clip* clip )
 {
+
+    if ( m_selectedClip != NULL && clip != NULL &&
+         clip->uuid() != m_selectedClip->uuid() )
+        clipUnloaded( m_selectedClip->uuid() );
     if ( clip == NULL )
     {
         m_selectedClip = NULL;
@@ -191,12 +195,6 @@ ClipRenderer::clipUnloaded( const QUuid& uuid )
     }
 }
 
-void
-ClipRenderer::clipUnloaded( const Clip *clip )
-{
-    clipUnloaded( clip->uuid() );
-}
-
 qint64
 ClipRenderer::getCurrentFrame() const
 {
diff --git a/src/Renderer/ClipRenderer.h b/src/Renderer/ClipRenderer.h
index e66c872..57b05ed 100644
--- a/src/Renderer/ClipRenderer.h
+++ b/src/Renderer/ClipRenderer.h
@@ -77,7 +77,6 @@ public slots:
      */
     void                    setClip( Clip* clip );
     void                    clipUnloaded( const QUuid& uuid );
-    void                    clipUnloaded( const Clip* clip );
     virtual void            previewWidgetCursorChanged( qint64 newFrame );
     void                    updateInfos( Clip* clip );
 



More information about the Vlmc-devel mailing list