[vlmc-devel] commit: Library: Solving potential race condition. (Hugo Beauzee-Luyssen )
git at videolan.org
git at videolan.org
Sat Mar 13 15:23:04 CET 2010
vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Sat Mar 13 15:12:15 2010 +0100| [68a892848bcf0ccca4ff6ea5be79ccc06223c716] | committer: Hugo Beauzee-Luyssen
Library: Solving potential race condition.
Removed unused includes (I mean... a QProgressBar in the library backend
? come one !! :D )
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=68a892848bcf0ccca4ff6ea5be79ccc06223c716
---
src/Library/Library.cpp | 9 +++------
src/Library/Library.h | 11 +++--------
2 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/src/Library/Library.cpp b/src/Library/Library.cpp
index ed37022..87acdfd 100644
--- a/src/Library/Library.cpp
+++ b/src/Library/Library.cpp
@@ -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();
}
diff --git a/src/Library/Library.h b/src/Library/Library.h
index 253874e..d112e97 100644
--- a/src/Library/Library.h
+++ b/src/Library/Library.h
@@ -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:
/**
More information about the Vlmc-devel
mailing list