Lock access to MTP devices - if two threads try to connect at once it causes a crash

This commit is contained in:
David Sansome 2010-08-29 13:49:24 +00:00
parent 70bea1bff4
commit 2f505aeb02
1 changed files with 4 additions and 0 deletions

View File

@ -55,12 +55,15 @@ void MtpDevice::Init() {
connect(loader_, SIGNAL(TaskStarted(int)), SIGNAL(TaskStarted(int)));
connect(loader_, SIGNAL(LoadFinished()), SLOT(LoadFinished()));
connect(loader_thread_, SIGNAL(started()), loader_, SLOT(LoadDatabase()));
db_busy_.lock();
loader_thread_->start();
}
void MtpDevice::LoadFinished() {
loader_->deleteLater();
loader_ = NULL;
db_busy_.unlock();
}
void MtpDevice::StartCopy() {
@ -160,6 +163,7 @@ QList<Song::FileType> MtpDevice::SupportedFiletypes() {
uint16_t* list = NULL;
uint16_t length = 0;
QMutexLocker l(&db_busy_);
MtpConnection connection(url_.host());
if (LIBMTP_Get_Supported_Filetypes(connection.device(), &list, &length)
|| !list || !length)