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