Commit 9a5346a3 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

MetadataWorker: Fix crash in case of VLC error

parent d6be76a0
......@@ -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;
......
......@@ -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();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment