Put a mutex around all the taglib stuff

This commit is contained in:
David Sansome 2010-08-08 12:35:23 +00:00
parent 23c02830de
commit 49da0eee27
2 changed files with 6 additions and 0 deletions

View File

@ -128,6 +128,8 @@ static TagLib::String QStringToTaglibString(const QString& s);
TagLibFileRefFactory Song::kDefaultFactory;
QMutex Song::taglib_mutex_;
Song::Private::Private()
: valid_(false),
@ -197,6 +199,7 @@ void Song::InitFromFile(const QString& filename, int directory_id) {
d->filename_ = filename;
d->directory_id_ = directory_id;
QMutexLocker l(&taglib_mutex_);
scoped_ptr<TagLib::FileRef> fileref(factory_->GetFileRef(filename));
if(fileref->isNull())
@ -638,6 +641,7 @@ bool Song::Save() const {
if (d->filename_.isNull())
return false;
QMutexLocker l(&taglib_mutex_);
scoped_ptr<TagLib::FileRef> fileref(factory_->GetFileRef(d->filename_));
if (!fileref || fileref->isNull()) // The file probably doesn't exist

View File

@ -256,6 +256,8 @@ class Song {
FileRefFactory* factory_;
static TagLibFileRefFactory kDefaultFactory;
static QMutex taglib_mutex_;
};
Q_DECLARE_METATYPE(Song);