mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
* Remove albums from internal cache when destroying them.
This commit is contained in:
@@ -73,7 +73,7 @@ Album::get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCr
|
|||||||
return album.toStrongRef();
|
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->setWeakRef( album.toWeakRef() );
|
||||||
album->loadId( autoCreate );
|
album->loadId( autoCreate );
|
||||||
s_albumsByName.insert( key, album );
|
s_albumsByName.insert( key, album );
|
||||||
@@ -105,7 +105,7 @@ Album::get( unsigned int id, const QString& name, const Tomahawk::artist_ptr& ar
|
|||||||
return album;
|
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() );
|
a->setWeakRef( a.toWeakRef() );
|
||||||
s_albumsByName.insert( key, a );
|
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
|
void
|
||||||
Album::onTracksLoaded( Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection )
|
Album::onTracksLoaded( Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection )
|
||||||
{
|
{
|
||||||
|
@@ -68,6 +68,9 @@ public:
|
|||||||
|
|
||||||
void loadId( bool autoCreate );
|
void loadId( bool autoCreate );
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void deleteLater();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection );
|
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection );
|
||||||
void updated();
|
void updated();
|
||||||
|
Reference in New Issue
Block a user