[vlmc-devel] commit: Metadata Worker: Avoid a crash when an image fails to load. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Sun Oct 31 19:52:14 CET 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Oct 31 19:16:20 2010 +0100| [03b7f973534736df12526b48cb855edee4f8a618] | committer: Hugo Beauzée-Luyssen 

Metadata Worker: Avoid a crash when an image fails to load.

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

 src/Metadata/MetaDataWorker.cpp |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/Metadata/MetaDataWorker.cpp b/src/Metadata/MetaDataWorker.cpp
index 94eafc1..aa890c7 100644
--- a/src/Metadata/MetaDataWorker.cpp
+++ b/src/Metadata/MetaDataWorker.cpp
@@ -59,22 +59,25 @@ MetaDataWorker::~MetaDataWorker()
 void
 MetaDataWorker::compute()
 {
-    if ( m_media->fileType() == Media::Video ||
-         m_media->fileType() == Media::Audio )
+    if ( m_media->fileType() == Media::Video || m_media->fileType() == Media::Audio )
         computeDynamicFileMetaData();
     else if ( m_media->fileType() == Media::Image )
         computeImageMetaData();
 
     m_media->addConstantParam( ":vout=dummy" );
     m_mediaPlayer->setMedia( m_media->vlcMedia() );
-    connect( m_lengthChangedTimer, SIGNAL( timeout() ),
-             this, SLOT( lengthChangedTimeout() ), Qt::QueuedConnection );
     connect( m_mediaPlayer, SIGNAL( playing() ),
              this, SLOT( entrypointPlaying() ), Qt::QueuedConnection );
     connect( m_mediaPlayer, SIGNAL( errorEncountered() ), this, SLOT( failure() ) );
     connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( failure() ) );
     m_mediaPlayer->play();
-    m_lengthChangedTimer->start( 3000 );
+
+    if ( m_media->fileType() == Media::Video || m_media->fileType() == Media::Audio )
+    {
+        connect( m_lengthChangedTimer, SIGNAL( timeout() ),
+                 this, SLOT( lengthChangedTimeout() ), Qt::QueuedConnection );
+        m_lengthChangedTimer->start( 3000 );
+    }
     m_media->flushVolatileParameters();
 }
 
@@ -211,6 +214,11 @@ MetaDataWorker::finalize()
 void
 MetaDataWorker::lengthChangedTimeout()
 {
+    /**
+     *  If we fail to compute a length, let's assume the file can't be used for video editing.
+     *  In that case, the ImportManager will ask the user if he wishes to convert it.
+     *  In any case, load the file for now.
+     */
     //No race condition possible, since both lengthChanged methods are called from the Qt event loop.
     m_lengthChangedTimer->disconnect();
     if ( m_lengthHasChanged == true )
@@ -251,7 +259,6 @@ MetaDataWorker::failure()
     deleteLater();
 }
 
-
 //void
 //MetaDataWorker::prepareAudioSpectrumComputing()
 //{



More information about the Vlmc-devel mailing list