From 3b2ac21dbf4d56aa3363a23d195cc8805c9505ac Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 11 Dec 2014 00:35:44 +0100 Subject: [PATCH] Remove script collections before trying to add a new collection. If latter fails no invalid collections are removed --- src/libtomahawk/resolvers/JSResolver.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libtomahawk/resolvers/JSResolver.cpp b/src/libtomahawk/resolvers/JSResolver.cpp index 81591ab4c..d5dae8970 100644 --- a/src/libtomahawk/resolvers/JSResolver.cpp +++ b/src/libtomahawk/resolvers/JSResolver.cpp @@ -770,6 +770,12 @@ JSResolver::loadCollections() if ( d->capabilities.testFlag( Browsable ) ) { + + foreach ( Tomahawk::collection_ptr collection, m_collections ) + { + emit collectionRemoved( collection ); + } + const QVariantMap collectionInfo = callOnResolver( "collection()" ).toMap(); if ( collectionInfo.isEmpty() || !collectionInfo.contains( "prettyname" ) || @@ -779,11 +785,6 @@ JSResolver::loadCollections() const QString prettyname = collectionInfo.value( "prettyname" ).toString(); const QString desc = collectionInfo.value( "description" ).toString(); - foreach ( Tomahawk::collection_ptr collection, m_collections ) - { - emit collectionRemoved( collection ); - } - m_collections.clear(); // 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 );