[vlmc-devel] [PATCH] Fix guessing as a wrong type of media when its onMetaDataComputed is not yet called

Yikai Lu luyikei.qmltu at gmail.com
Sun Apr 10 17:52:54 CEST 2016


If loading in MainWorkflow is too fast to compute media's metadata, it's highly likely that the workflow will misjudge the type of ClipWorkflow.
---
 src/Library/MediaContainer.cpp | 6 ++++--
 src/Media/Media.cpp            | 5 ++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/Library/MediaContainer.cpp b/src/Library/MediaContainer.cpp
index a0b3364..574cb95 100644
--- a/src/Library/MediaContainer.cpp
+++ b/src/Library/MediaContainer.cpp
@@ -195,7 +195,9 @@ MediaContainer::count() const
 Media*
 MediaContainer::createMediaFromVariant( const QVariant& var )
 {
-    Media* m = addMedia( QFileInfo( var.toString() ) );
+    auto map = var.toMap();
+    Media* m = addMedia( QFileInfo( map["path"].toString() ) );
+    m->setFileType( (Media::FileType) map["type"].toInt() );
     return m;
 }
 
@@ -209,7 +211,7 @@ MediaContainer::createClipFromVariant( const QVariant &var, Clip* parent )
         c = new Clip( parent, h["begin"].toULongLong(),
                 h["end"].toULongLong(), h["uuid"].toString() );
     else {
-        c = new Clip( m_medias[ h["media"].toString() ], 0, -1, h["uuid"].toString() );
+        c = new Clip( m_medias[ h["media"].toMap()["path"].toString() ], 0, -1, h["uuid"].toString() );
         addClip( c );
     }
     if ( h.contains( "subClips" ) )
diff --git a/src/Media/Media.cpp b/src/Media/Media.cpp
index 9f708f1..cdbbd31 100644
--- a/src/Media/Media.cpp
+++ b/src/Media/Media.cpp
@@ -151,7 +151,10 @@ Media::onMetaDataComputed()
 QVariant
 Media::toVariant() const
 {
-    return QVariant( m_fileInfo->absoluteFilePath() );
+    return QVariant( QVariantHash {
+                         { "path", m_fileInfo->absoluteFilePath() },
+                         { "type", (int) m_fileType }
+                     } );
 }
 
 void
-- 
1.9.1



More information about the Vlmc-devel mailing list