1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

* Prevent race condition.

(cherry picked from commit ebbedb2b99)
This commit is contained in:
Christian Muehlhaeuser
2012-03-17 12:10:09 +01:00
committed by Leo Franchi
parent 95f1162b6e
commit ace18dfa1f
3 changed files with 13 additions and 10 deletions

View File

@@ -143,8 +143,9 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
url = QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url );
}
bool cached = Tomahawk::Result::isCached( url );
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
if ( result->isValid() )
if ( cached )
{
qDebug() << "Result already cached:" << result->toString();
res << result;
@@ -281,8 +282,9 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
url = QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url );
}
bool cached = Tomahawk::Result::isCached( url );
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
if ( result->isValid() )
if ( cached )
{
qDebug() << "Result already cached:" << result->toString();
res << result;

View File

@@ -50,6 +50,14 @@ Result::get( const QString& url )
}
bool
Result::isCached( const QString& url )
{
QMutexLocker lock( &s_mutex );
return ( s_results.contains( url ) );
}
Result::Result( const QString& url )
: QObject()
, m_url( url )
@@ -86,13 +94,6 @@ Result::deleteLater()
}
bool
Result::isValid() const
{
return !m_rid.isEmpty();
}
artist_ptr
Result::artist() const
{

View File

@@ -56,9 +56,9 @@ friend class ::DatabaseCommand_LoadFile;
public:
static Tomahawk::result_ptr get( const QString& url );
static bool isCached( const QString& url );
virtual ~Result();
bool isValid() const;
QVariant toVariant() const;
QString toString() const;
Tomahawk::query_ptr toQuery();