mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
* Fixed race condition during resolving.
This commit is contained in:
@@ -55,9 +55,6 @@ DatabaseCommand_Resolve::exec( DatabaseImpl* lib )
|
|||||||
qDebug() << "Using result-hint to speed up resolving:" << m_query->resultHint();
|
qDebug() << "Using result-hint to speed up resolving:" << m_query->resultHint();
|
||||||
|
|
||||||
Tomahawk::result_ptr result = lib->resultFromHint( m_query );
|
Tomahawk::result_ptr result = lib->resultFromHint( m_query );
|
||||||
/* qDebug() << "Result null:" << result.isNull();
|
|
||||||
* qDebug() << "Collection null:" << result->collection().isNull();
|
|
||||||
* qDebug() << "Source null:" << result->collection()->source().isNull();*/
|
|
||||||
if ( !result.isNull() && !result->collection().isNull() && result->collection()->source()->isOnline() )
|
if ( !result.isNull() && !result->collection().isNull() && result->collection()->source()->isOnline() )
|
||||||
{
|
{
|
||||||
QList<Tomahawk::result_ptr> res;
|
QList<Tomahawk::result_ptr> res;
|
||||||
@@ -137,7 +134,7 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = SourceList::instance()->get( files_query.value( 16 ).toUInt() );
|
s = SourceList::instance()->get( files_query.value( 16 ).toUInt() );
|
||||||
if( s.isNull() )
|
if ( s.isNull() )
|
||||||
{
|
{
|
||||||
qDebug() << "Could not find source" << files_query.value( 16 ).toUInt();
|
qDebug() << "Could not find source" << files_query.value( 16 ).toUInt();
|
||||||
continue;
|
continue;
|
||||||
@@ -147,12 +144,15 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
|
|||||||
}
|
}
|
||||||
|
|
||||||
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
|
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
|
||||||
Tomahawk::artist_ptr artist =
|
if ( result->isValid() )
|
||||||
Tomahawk::Artist::get( files_query.value( 18 ).toUInt(), files_query.value( 12 ).toString() );
|
{
|
||||||
Tomahawk::album_ptr album =
|
qDebug() << "Result already cached:" << result->toString();
|
||||||
Tomahawk::Album::get( files_query.value( 19 ).toUInt(), files_query.value( 13 ).toString(), artist );
|
continue;
|
||||||
Tomahawk::artist_ptr composer =
|
}
|
||||||
Tomahawk::Artist::get( files_query.value( 20 ).toUInt(), files_query.value( 15 ).toString() );
|
|
||||||
|
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( files_query.value( 18 ).toUInt(), files_query.value( 12 ).toString() );
|
||||||
|
Tomahawk::album_ptr album = Tomahawk::Album::get( files_query.value( 19 ).toUInt(), files_query.value( 13 ).toString(), artist );
|
||||||
|
Tomahawk::artist_ptr composer = Tomahawk::Artist::get( files_query.value( 20 ).toUInt(), files_query.value( 15 ).toString() );
|
||||||
|
|
||||||
result->setModificationTime( files_query.value( 1 ).toUInt() );
|
result->setModificationTime( files_query.value( 1 ).toUInt() );
|
||||||
result->setSize( files_query.value( 2 ).toUInt() );
|
result->setSize( files_query.value( 2 ).toUInt() );
|
||||||
@@ -181,6 +181,7 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
|
|||||||
|
|
||||||
result->setAttributes( attr );
|
result->setAttributes( attr );
|
||||||
result->setCollection( s->collection() );
|
result->setCollection( s->collection() );
|
||||||
|
|
||||||
res << result;
|
res << result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +271,7 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = SourceList::instance()->get( files_query.value( 16 ).toUInt() );
|
s = SourceList::instance()->get( files_query.value( 16 ).toUInt() );
|
||||||
if( s.isNull() )
|
if ( s.isNull() )
|
||||||
{
|
{
|
||||||
qDebug() << "Could not find source" << files_query.value( 16 ).toUInt();
|
qDebug() << "Could not find source" << files_query.value( 16 ).toUInt();
|
||||||
continue;
|
continue;
|
||||||
@@ -280,12 +281,15 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
|
|||||||
}
|
}
|
||||||
|
|
||||||
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
|
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
|
||||||
Tomahawk::artist_ptr artist =
|
if ( result->isValid() )
|
||||||
Tomahawk::Artist::get( files_query.value( 18 ).toUInt(), files_query.value( 12 ).toString() );
|
{
|
||||||
Tomahawk::album_ptr album =
|
qDebug() << "Result already cached:" << result->toString();
|
||||||
Tomahawk::Album::get( files_query.value( 19 ).toUInt(), files_query.value( 13 ).toString(), artist );
|
continue;
|
||||||
Tomahawk::artist_ptr composer =
|
}
|
||||||
Tomahawk::Artist::get( files_query.value( 20 ).toUInt(), files_query.value( 15 ).toString() );
|
|
||||||
|
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( files_query.value( 18 ).toUInt(), files_query.value( 12 ).toString() );
|
||||||
|
Tomahawk::album_ptr album = Tomahawk::Album::get( files_query.value( 19 ).toUInt(), files_query.value( 13 ).toString(), artist );
|
||||||
|
Tomahawk::artist_ptr composer = Tomahawk::Artist::get( files_query.value( 20 ).toUInt(), files_query.value( 15 ).toString() );
|
||||||
|
|
||||||
result->setModificationTime( files_query.value( 1 ).toUInt() );
|
result->setModificationTime( files_query.value( 1 ).toUInt() );
|
||||||
result->setSize( files_query.value( 2 ).toUInt() );
|
result->setSize( files_query.value( 2 ).toUInt() );
|
||||||
@@ -322,8 +326,8 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
|
|||||||
}
|
}
|
||||||
|
|
||||||
result->setAttributes( attr );
|
result->setAttributes( attr );
|
||||||
|
|
||||||
result->setCollection( s->collection() );
|
result->setCollection( s->collection() );
|
||||||
|
|
||||||
res << result;
|
res << result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -43,7 +43,7 @@ Result::get( const QString& url )
|
|||||||
return s_results.value( url );
|
return s_results.value( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
result_ptr r = result_ptr( new Result( url ), &QObject::deleteLater );
|
result_ptr r = result_ptr( new Result( url ), &Result::deleteLater );
|
||||||
s_results.insert( url, r );
|
s_results.insert( url, r );
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
@@ -68,12 +68,28 @@ Result::Result( const QString& url )
|
|||||||
|
|
||||||
|
|
||||||
Result::~Result()
|
Result::~Result()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Result::deleteLater()
|
||||||
{
|
{
|
||||||
QMutexLocker lock( &s_mutex );
|
QMutexLocker lock( &s_mutex );
|
||||||
|
|
||||||
if ( s_results.contains( m_url ) )
|
if ( s_results.contains( m_url ) )
|
||||||
{
|
{
|
||||||
s_results.remove( m_url );
|
s_results.remove( m_url );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject::deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Result::isValid() const
|
||||||
|
{
|
||||||
|
return !m_rid.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -58,6 +58,7 @@ public:
|
|||||||
static Tomahawk::result_ptr get( const QString& url );
|
static Tomahawk::result_ptr get( const QString& url );
|
||||||
virtual ~Result();
|
virtual ~Result();
|
||||||
|
|
||||||
|
bool isValid() const;
|
||||||
QVariant toVariant() const;
|
QVariant toVariant() const;
|
||||||
QString toString() const;
|
QString toString() const;
|
||||||
Tomahawk::query_ptr toQuery();
|
Tomahawk::query_ptr toQuery();
|
||||||
@@ -108,6 +109,9 @@ public:
|
|||||||
unsigned int trackId() const { return m_trackId; }
|
unsigned int trackId() const { return m_trackId; }
|
||||||
unsigned int fileId() const { return m_fileId; }
|
unsigned int fileId() const { return m_fileId; }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void deleteLater();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// emitted when the collection this result comes from is going offline/online:
|
// emitted when the collection this result comes from is going offline/online:
|
||||||
void statusChanged();
|
void statusChanged();
|
||||||
|
Reference in New Issue
Block a user