mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-02-22 19:05:05 +01:00
* Remove albums from internal cache when destroying them.
This commit is contained in:
parent
d932aa6c2d
commit
5f32bdb277
@ -73,7 +73,7 @@ Album::get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCr
|
||||
return album.toStrongRef();
|
||||
}
|
||||
|
||||
album_ptr album = album_ptr( new Album( name, artist ) );
|
||||
album_ptr album = album_ptr( new Album( name, artist ), &Album::deleteLater );
|
||||
album->setWeakRef( album.toWeakRef() );
|
||||
album->loadId( autoCreate );
|
||||
s_albumsByName.insert( key, album );
|
||||
@ -105,7 +105,7 @@ Album::get( unsigned int id, const QString& name, const Tomahawk::artist_ptr& ar
|
||||
return album;
|
||||
}
|
||||
|
||||
album_ptr a = album_ptr( new Album( id, name, artist ), &QObject::deleteLater );
|
||||
album_ptr a = album_ptr( new Album( id, name, artist ), &Album::deleteLater );
|
||||
a->setWeakRef( a.toWeakRef() );
|
||||
s_albumsByName.insert( key, a );
|
||||
|
||||
@ -153,6 +153,31 @@ Album::Album( const QString& name, const Tomahawk::artist_ptr& artist )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Album::deleteLater()
|
||||
{
|
||||
QMutexLocker lock( &s_nameCacheMutex );
|
||||
|
||||
const QString key = albumCacheKey( m_artist, m_name );
|
||||
if ( s_albumsByName.contains( key ) )
|
||||
{
|
||||
s_albumsByName.remove( key );
|
||||
}
|
||||
|
||||
if ( m_id > 0 )
|
||||
{
|
||||
s_idMutex.lockForWrite();
|
||||
if ( s_albumsById.contains( m_id ) )
|
||||
{
|
||||
s_albumsById.remove( m_id );
|
||||
}
|
||||
s_idMutex.unlock();
|
||||
}
|
||||
|
||||
QObject::deleteLater();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Album::onTracksLoaded( Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection )
|
||||
{
|
||||
|
@ -68,6 +68,9 @@ public:
|
||||
|
||||
void loadId( bool autoCreate );
|
||||
|
||||
public slots:
|
||||
void deleteLater();
|
||||
|
||||
signals:
|
||||
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection );
|
||||
void updated();
|
||||
|
Loading…
x
Reference in New Issue
Block a user