From d554dbc6fd1043ef5ef31cc95386be477a8d54ac Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Thu, 16 May 2013 11:15:51 +0200 Subject: [PATCH] * Artist id must be >0 when initializing it with pre-loaded data. --- src/libtomahawk/Artist.cpp | 5 ++++- src/libtomahawk/Artist.h | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/Artist.cpp b/src/libtomahawk/Artist.cpp index 4f61307f7..c2498ccf6 100644 --- a/src/libtomahawk/Artist.cpp +++ b/src/libtomahawk/Artist.cpp @@ -43,6 +43,7 @@ QHash< unsigned int, artist_wptr > Artist::s_artistsById = QHash< unsigned int, static QMutex s_nameCacheMutex; static QReadWriteLock s_idMutex; + Artist::~Artist() { tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Deleting artist:" << m_name; @@ -65,7 +66,7 @@ Artist::get( const QString& name, bool autoCreate ) if ( s_artistsByName.contains( key ) ) { artist_wptr artist = s_artistsByName.value( key ); - if ( !artist.isNull() ) + if ( artist ) return artist.toStrongRef(); } @@ -84,6 +85,8 @@ Artist::get( const QString& name, bool autoCreate ) artist_ptr Artist::get( unsigned int id, const QString& name ) { + Q_ASSERT( id > 0 ); + s_idMutex.lockForRead(); if ( s_artistsById.contains( id ) ) { diff --git a/src/libtomahawk/Artist.h b/src/libtomahawk/Artist.h index 88ed10b37..c9bd14fb7 100644 --- a/src/libtomahawk/Artist.h +++ b/src/libtomahawk/Artist.h @@ -31,7 +31,6 @@ #include "DllMacro.h" #include "Query.h" - class IdThreadWorker; namespace Tomahawk