diff --git a/src/libtomahawk/database/databasecommand_addfiles.cpp b/src/libtomahawk/database/databasecommand_addfiles.cpp index 0036e671d..56f36ebbe 100644 --- a/src/libtomahawk/database/databasecommand_addfiles.cpp +++ b/src/libtomahawk/database/databasecommand_addfiles.cpp @@ -186,7 +186,8 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi ) qDebug() << "Inserted" << added; // TODO building the index could be a separate job, outside this transaction - dbi->updateSearchIndex(); + if ( added ) + dbi->updateSearchIndex(); qDebug() << "Committing" << added << "tracks..."; emit done( m_files, source()->collection() ); diff --git a/src/libtomahawk/sourcelist.cpp b/src/libtomahawk/sourcelist.cpp index 35e195664..3fac54e0e 100644 --- a/src/libtomahawk/sourcelist.cpp +++ b/src/libtomahawk/sourcelist.cpp @@ -61,9 +61,13 @@ SourceList::add( const Tomahawk::source_ptr& s ) void -SourceList::remove( const Tomahawk::source_ptr& s ) +SourceList::remove( Tomahawk::source_ptr& s ) { + if ( s.isNull() ) + return; + remove( s.data() ); + s.clear(); } @@ -87,13 +91,12 @@ SourceList::remove( Tomahawk::Source* s ) } emit sourceRemoved( src ); - src.clear(); } void SourceList::removeAllRemote() { - foreach( const source_ptr& s, m_sources ) + foreach( source_ptr s, m_sources ) { if( s != m_local ) remove( s ); diff --git a/src/libtomahawk/sourcelist.h b/src/libtomahawk/sourcelist.h index 1f3363e97..7a776535d 100644 --- a/src/libtomahawk/sourcelist.h +++ b/src/libtomahawk/sourcelist.h @@ -21,7 +21,7 @@ public: const Tomahawk::source_ptr& getLocal(); void add( const Tomahawk::source_ptr& s ); - void remove( const Tomahawk::source_ptr& s ); + void remove( Tomahawk::source_ptr& s ); void remove( Tomahawk::Source* s ); void removeAllRemote();