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:
12
thirdparty/liblastfm2/src/ws/ws.cpp
vendored
12
thirdparty/liblastfm2/src/ws/ws.cpp
vendored
@@ -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;
|
||||
|
Reference in New Issue
Block a user