Commit 68a89284 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Library: Solving potential race condition.

Removed unused includes (I mean... a QProgressBar in the library backend
? come one !! :D )
parent 94e97152
...@@ -38,10 +38,6 @@ ...@@ -38,10 +38,6 @@
#include <QUuid> #include <QUuid>
#include <QXmlStreamWriter> #include <QXmlStreamWriter>
Library::Library() : m_nbMediaToLoad( 0 )
{
}
void void
Library::loadProject( const QDomElement& doc ) Library::loadProject( const QDomElement& doc )
{ {
...@@ -50,6 +46,7 @@ Library::loadProject( const QDomElement& doc ) ...@@ -50,6 +46,7 @@ Library::loadProject( const QDomElement& doc )
if ( medias.isNull() == true ) if ( medias.isNull() == true )
return ; return ;
m_nbMediaToLoad = 0;
QDomElement media = medias.firstChild().toElement(); QDomElement media = medias.firstChild().toElement();
while ( media.isNull() == false ) while ( media.isNull() == false )
{ {
...@@ -60,7 +57,7 @@ Library::loadProject( const QDomElement& doc ) ...@@ -60,7 +57,7 @@ Library::loadProject( const QDomElement& doc )
connect( m, SIGNAL( metaDataComputed( const Media* ) ), connect( m, SIGNAL( metaDataComputed( const Media* ) ),
this, SLOT( mediaLoaded( const Media* ) ), Qt::QueuedConnection ); this, SLOT( mediaLoaded( const Media* ) ), Qt::QueuedConnection );
m_medias[mrl] = m; m_medias[mrl] = m;
++m_nbMediaToLoad; m_nbMediaToLoad.fetchAndAddAcquire( 1 );
} }
media = media.nextSibling().toElement(); media = media.nextSibling().toElement();
} }
...@@ -93,7 +90,7 @@ Library::mediaLoaded( const Media* media ) ...@@ -93,7 +90,7 @@ Library::mediaLoaded( const Media* media )
{ {
disconnect( media, SIGNAL( metaDataComputed( const Media* ) ), disconnect( media, SIGNAL( metaDataComputed( const Media* ) ),
this, SLOT( mediaLoaded( const Media* ) ) ); this, SLOT( mediaLoaded( const Media* ) ) );
--m_nbMediaToLoad; m_nbMediaToLoad.fetchAndAddAcquire( -1 );
if ( m_nbMediaToLoad == 0 ) if ( m_nbMediaToLoad == 0 )
emit projectLoaded(); emit projectLoaded();
} }
...@@ -33,13 +33,8 @@ ...@@ -33,13 +33,8 @@
#include "Singleton.hpp" #include "Singleton.hpp"
#include "MediaContainer.h" #include "MediaContainer.h"
#include <QHash>
#include <QObject> #include <QObject>
#include <QUuid> #include <QAtomicInt>
#include <QFileInfo>
#include <QMutex>
#include <QMutexLocker>
#include <QProgressDialog>
class QXmlStreamWriter; class QXmlStreamWriter;
class QDomElement; class QDomElement;
...@@ -57,11 +52,11 @@ class Library : public MediaContainer, public Singleton<Library> ...@@ -57,11 +52,11 @@ class Library : public MediaContainer, public Singleton<Library>
Q_DISABLE_COPY( Library ); Q_DISABLE_COPY( Library );
private: private:
Library(); Library() {}
virtual ~Library(){} virtual ~Library(){}
private: private:
quint32 m_nbMediaToLoad; QAtomicInt m_nbMediaToLoad;
public slots: public slots:
/** /**
......
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