1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-19 04:11:46 +02:00

A fix for the introduced crash in liblastfm, ready for more lfranchi debugging

This commit is contained in:
Jeff Mitchell
2011-05-03 16:58:10 -04:00
parent dd4d268c11
commit 97ca55fd53
9 changed files with 21 additions and 9 deletions

View File

@@ -30,7 +30,7 @@
#include <QUrl>
static QMap< QThread*, QNetworkAccessManager* > threadNamHash;
static QMap< QThread*, bool > ourNamHash;
static QSet< QThread* > ourNamSet;
static QMutex namAccessMutex;
QString
@@ -205,10 +205,11 @@ lastfm::nam()
qDebug() << Q_FUNC_INFO << " does not yet have a NAM, creating a new one";
NetworkAccessManager* newNam = new NetworkAccessManager();
threadNamHash[thread] = newNam;
ourNamHash[thread] = true;
ourNamSet.insert( thread );
qDebug() << Q_FUNC_INFO << " returning " << threadNamHash[thread];
return newNam;
}
Q_ASSERT( threadNamHash[thread] );
qDebug() << Q_FUNC_INFO << " found a nam, is " << threadNamHash[thread];
return threadNamHash[thread];
}
@@ -223,11 +224,14 @@ lastfm::setNetworkAccessManager( QNetworkAccessManager* nam )
QMutexLocker l( &namAccessMutex );
QThread* thread = QThread::currentThread();
QNetworkAccessManager* oldNam = 0;
if ( threadNamHash.contains( thread ) && ourNamHash.contains( thread ) && ourNamHash[thread] )
if ( threadNamHash.contains( thread ) && ourNamSet.contains( thread ) )
oldNam = threadNamHash[thread];
if ( oldNam == nam )
return;
threadNamHash[thread] = nam;
ourNamHash[thread] = false;
ourNamSet.remove( thread );
if ( oldNam )
delete oldNam;