1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-13 17:43:59 +02:00

Remove script collections before trying to add a new collection. If latter fails no invalid collections are removed

This commit is contained in:
Dominik Schmidt
2014-12-11 00:35:44 +01:00
parent 7d114ea0f3
commit 3b2ac21dbf

View File

@@ -770,6 +770,12 @@ JSResolver::loadCollections()
if ( d->capabilities.testFlag( Browsable ) ) if ( d->capabilities.testFlag( Browsable ) )
{ {
foreach ( Tomahawk::collection_ptr collection, m_collections )
{
emit collectionRemoved( collection );
}
const QVariantMap collectionInfo = callOnResolver( "collection()" ).toMap(); const QVariantMap collectionInfo = callOnResolver( "collection()" ).toMap();
if ( collectionInfo.isEmpty() || if ( collectionInfo.isEmpty() ||
!collectionInfo.contains( "prettyname" ) || !collectionInfo.contains( "prettyname" ) ||
@@ -779,11 +785,6 @@ JSResolver::loadCollections()
const QString prettyname = collectionInfo.value( "prettyname" ).toString(); const QString prettyname = collectionInfo.value( "prettyname" ).toString();
const QString desc = collectionInfo.value( "description" ).toString(); const QString desc = collectionInfo.value( "description" ).toString();
foreach ( Tomahawk::collection_ptr collection, m_collections )
{
emit collectionRemoved( collection );
}
m_collections.clear(); m_collections.clear();
// at this point we assume that all the tracks browsable through a resolver belong to the local source // at this point we assume that all the tracks browsable through a resolver belong to the local source
Tomahawk::ScriptCollection* sc = new Tomahawk::ScriptCollection( collectionInfo[ "id" ].toString(), SourceList::instance()->getLocal(), this ); Tomahawk::ScriptCollection* sc = new Tomahawk::ScriptCollection( collectionInfo[ "id" ].toString(), SourceList::instance()->getLocal(), this );