[vlmc-devel] MetadataWorker: Fix crash in case of VLC error

Hugo Beauzée-Luyssen git at videolan.org
Sun Sep 2 13:37:35 CEST 2012


vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Sun Sep  2 12:09:35 2012 +0300| [9a5346a374278314b92e6d0ff80cc8d811e289f7] | committer: Hugo Beauzée-Luyssen

MetadataWorker: Fix crash in case of VLC error

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

 src/Metadata/MetaDataManager.cpp |    1 +
 src/Metadata/MetaDataWorker.cpp  |    9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/Metadata/MetaDataManager.cpp b/src/Metadata/MetaDataManager.cpp
index e6247c0..f6a18a2 100644
--- a/src/Metadata/MetaDataManager.cpp
+++ b/src/Metadata/MetaDataManager.cpp
@@ -62,6 +62,7 @@ MetaDataManager::computingCompleted()
 {
     QMutexLocker lock( m_computingMutex );
 
+    Q_ASSERT_X(m_mediaPlayer, __FUNCTION__, "No media player instance. Event handling is probably broken");
     m_mediaPlayer->stop();
     delete m_mediaPlayer;
     m_mediaPlayer = NULL;
diff --git a/src/Metadata/MetaDataWorker.cpp b/src/Metadata/MetaDataWorker.cpp
index e3415a3..265b907 100644
--- a/src/Metadata/MetaDataWorker.cpp
+++ b/src/Metadata/MetaDataWorker.cpp
@@ -68,8 +68,12 @@ MetaDataWorker::compute()
     m_mediaPlayer->setMedia( m_media->vlcMedia() );
     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() ) );
+    //We want to disconnect the media player ASAP once an error is encountered,
+    //therefor we use direct connection. The failure() slot will be disconnected
+    //as soon as the first error will be encountered.
+    connect( m_mediaPlayer, SIGNAL( errorEncountered() ), this, SLOT( failure() ), Qt::DirectConnection );
+    //When a codec is not found, no error is raised, but endReached will.
+    connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( failure() ), Qt::DirectConnection );
     m_mediaPlayer->play();
 
     if ( m_media->fileType() == Media::Video || m_media->fileType() == Media::Audio )
@@ -263,6 +267,7 @@ MetaDataWorker::entrypointPlaying()
 void
 MetaDataWorker::failure()
 {
+    m_mediaPlayer->disconnect( this );
     emit failed( m_media );
     deleteLater();
 }



More information about the Vlmc-devel mailing list