mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 00:09:47 +01:00
Fix hang in suggestion list loading and share amongst all controls
This commit is contained in:
parent
597e459db1
commit
aafec62d45
@ -29,6 +29,7 @@
|
||||
#include <qcompleter.h>
|
||||
#include <qstringlistmodel.h>
|
||||
|
||||
QHash< QString, QStringList > Tomahawk::EchonestControl::s_suggestCache = QHash< QString, QStringList >();
|
||||
|
||||
Tomahawk::EchonestControl::EchonestControl( const QString& selectedType, const QStringList& typeSelectors, QObject* parent )
|
||||
: DynamicControl ( selectedType.isEmpty() ? "Artist" : selectedType, typeSelectors, parent )
|
||||
@ -572,8 +573,8 @@ Tomahawk::EchonestControl::artistTextEdited( const QString& text )
|
||||
m_suggestWorkers.clear();
|
||||
|
||||
if( !text.isEmpty() ) {
|
||||
if( m_suggestCache.contains( text ) ) {
|
||||
addArtistSuggestions( m_suggestCache[ text ] );
|
||||
if( s_suggestCache.contains( text ) ) {
|
||||
addArtistSuggestions( s_suggestCache[ text ] );
|
||||
} else { // gotta look it up
|
||||
QNetworkReply* r = Echonest::Artist::suggest( text );
|
||||
qDebug() << "Asking echonest for suggestions to help our completion..." << r->url().toString();
|
||||
@ -615,7 +616,7 @@ Tomahawk::EchonestControl::suggestFinished()
|
||||
return;
|
||||
}
|
||||
|
||||
m_suggestCache[ origText ] = suggestions;
|
||||
s_suggestCache[ origText ] = suggestions;
|
||||
addArtistSuggestions( suggestions );
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ private:
|
||||
QVariant m_cacheData;
|
||||
|
||||
QSet< QNetworkReply* > m_suggestWorkers;
|
||||
QHash< QString, QStringList > m_suggestCache;
|
||||
static QHash< QString, QStringList > s_suggestCache;
|
||||
|
||||
friend class EchonestGenerator;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user