[vlmc-devel] commit: Don't automatically create the Media's base clip. ( Hugo Beauzee-Luyssen )

git at videolan.org git at videolan.org
Sat Mar 13 14:07:46 CET 2010


vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Sat Mar 13 14:03:37 2010 +0100| [20a604d40ea743d0ba17f5f425af2aa3b7ad2ee0] | committer: Hugo Beauzee-Luyssen 

Don't automatically create the Media's base clip.

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

 src/Gui/import/ImportController.cpp |    6 ++++--
 src/Library/Library.cpp             |    1 +
 src/Library/MediaContainer.cpp      |    8 ++------
 src/Media/Media.cpp                 |    8 +++++++-
 src/Media/Media.h                   |    1 +
 5 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/Gui/import/ImportController.cpp b/src/Gui/import/ImportController.cpp
index b792c42..22eeb01 100644
--- a/src/Gui/import/ImportController.cpp
+++ b/src/Gui/import/ImportController.cpp
@@ -171,8 +171,10 @@ ImportController::importMedia( const QString &filePath )
     ++m_nbMediaToLoad;
     m_ui->progressBar->setMaximum( m_nbMediaToLoad );
 
-    Media* media = m_temporaryMedias->addMedia( filePath );
-    m_temporaryMedias->addClip( media->baseClip() );
+    Media*  media = m_temporaryMedias->addMedia( filePath );
+    Clip*   clip = new Clip( media );
+    media->setBaseClip( clip );
+    m_temporaryMedias->addClip( clip );
     if ( media )
         connect( media, SIGNAL( metaDataComputed( const Media* ) ),
                  this, SLOT( metaDataComputed( const Media* ) ) );
diff --git a/src/Library/Library.cpp b/src/Library/Library.cpp
index 67bab16..b73c9c7 100644
--- a/src/Library/Library.cpp
+++ b/src/Library/Library.cpp
@@ -61,6 +61,7 @@ Library::loadProject( const QDomElement& doc )
     if ( clips.isNull() == true )
         return ;
     load( clips, this );
+    qDebug() << m_clips;
     emit projectLoaded();
 }
 
diff --git a/src/Library/MediaContainer.cpp b/src/Library/MediaContainer.cpp
index cea6a2a..8565bd7 100644
--- a/src/Library/MediaContainer.cpp
+++ b/src/Library/MediaContainer.cpp
@@ -73,16 +73,12 @@ MediaContainer::addMedia( const QFileInfo& fileInfo, const QString& uuid )
 {
     if ( QFile::exists( fileInfo.absoluteFilePath() ) == false )
         return NULL;
-    Media* media = new Media( fileInfo.filePath(), uuid );
-
     foreach( Clip* it, m_clips.values() )
     {
-        if ( it->getMedia()->fileInfo()->filePath() == media->fileInfo()->filePath() )
-        {
-            delete media;
+        if ( it->getMedia()->fileInfo()->filePath() == fileInfo.filePath() )
             return NULL;
-        }
     }
+    Media* media = new Media( fileInfo.filePath(), uuid );
     MetaDataManager::getInstance()->computeMediaMetadata( media );
     return media;
 }
diff --git a/src/Media/Media.cpp b/src/Media/Media.cpp
index b3c873b..eb14706 100644
--- a/src/Media/Media.cpp
+++ b/src/Media/Media.cpp
@@ -77,7 +77,6 @@ Media::Media( const QString& filePath, const QString& uuid /*= QString()*/ )
         m_fileName = m_mrl;
         qDebug() << "Loading a stream";
     }
-    m_baseClip = new Clip( this, 0, -1, uuid );
     m_audioValueList = new QList<int>();
     m_vlcMedia = new LibVLCpp::Media( m_mrl );
 }
@@ -285,3 +284,10 @@ Media::save( QXmlStreamWriter& project )
     project.writeAttribute( "mrl", m_fileInfo->absoluteFilePath() );
     project.writeEndElement();
 }
+
+void
+Media::setBaseClip( Clip *clip )
+{
+    Q_ASSERT( m_baseClip == NULL );
+    m_baseClip = clip;
+}
diff --git a/src/Media/Media.h b/src/Media/Media.h
index f932566..ee8c264 100644
--- a/src/Media/Media.h
+++ b/src/Media/Media.h
@@ -139,6 +139,7 @@ public:
 
     Clip*                       baseClip() { return m_baseClip; }
     const Clip*                 baseClip() const { return m_baseClip; }
+    void                        setBaseClip( Clip* clip );
 
     bool                        isMetadataComputed() const;
 



More information about the Vlmc-devel mailing list