[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
Mon Apr 11 05:17:27 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 | 4 +++-
 src/Media/Clip.cpp             | 2 +-
 src/Media/Media.cpp            | 5 ++++-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/Library/MediaContainer.cpp b/src/Library/MediaContainer.cpp
index a0b3364..ec6b5a5 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;
 }
 
diff --git a/src/Media/Clip.cpp b/src/Media/Clip.cpp
index 4f29f8e..b0ad42e 100644
--- a/src/Media/Clip.cpp
+++ b/src/Media/Clip.cpp
@@ -241,7 +241,7 @@ Clip::toVariant() const
         { "notes", m_notes }
     };
     if ( isRootClip() )
-        h.insert( "media", m_media->toVariant() );
+        h.insert( "media", m_media->fileInfo()->absoluteFilePath() );
     else
     {
         h.insert( "parent", m_parent->uuid().toString() );
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