Commit 6d553d17 authored by Ludovic Fauvet's avatar Ludovic Fauvet
Browse files

Protect the library from concurrency with mutexes.

parent 2b858c46
......@@ -30,6 +30,7 @@ Library::Library()
Clip* Library::getClip( const QUuid& uuid )
{
QMutexLocker locker( &m_mutex );
QHash<QUuid, Clip*>::iterator it = m_clips.find( uuid );
if ( it == m_clips.end() )
return NULL;
......@@ -38,6 +39,7 @@ Clip* Library::getClip( const QUuid& uuid )
void Library::removingClipAsked( const QUuid& uuid )
{
QMutexLocker locker( &m_mutex );
QHash<QUuid, Clip*>::iterator it = m_clips.find( uuid );
if ( it == m_clips.end() )
return ;
......@@ -50,6 +52,7 @@ void Library::removingClipAsked( const QUuid& uuid )
void Library::newClipLoadingAsked( const QString& filePath )
{
QMutexLocker locker( &m_mutex );
Clip* clip;
foreach ( clip, m_clips )
{
......
......@@ -27,6 +27,8 @@
#include <QHash>
#include <QUuid>
#include <QFileInfo>
#include <QMutex>
#include <QMutexLocker>
#include "Clip.h"
#include "Singleton.hpp"
......@@ -51,6 +53,7 @@ public:
private:
Library();
QHash<QUuid, Clip*> m_clips;
QMutex m_mutex;
public slots:
void newClipLoadingAsked( const QString& filePath );
......
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