mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
Only lock once while accessing member objects.
Previously we locked/unlocked the internal mutex twice to get d->results. Also we created an unecessary copy of the list.
This commit is contained in:
@@ -166,8 +166,12 @@ track_ptr
|
|||||||
Query::track() const
|
Query::track() const
|
||||||
{
|
{
|
||||||
Q_D( const Query );
|
Q_D( const Query );
|
||||||
if ( !results().isEmpty() )
|
|
||||||
return results().first()->track();
|
{
|
||||||
|
QMutexLocker lock( &d->mutex );
|
||||||
|
if ( !d->results.isEmpty() )
|
||||||
|
return d->results.first()->track();
|
||||||
|
}
|
||||||
|
|
||||||
return d->queryTrack;
|
return d->queryTrack;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user