diff --git a/src/libtomahawk/playlist/XspfUpdater.cpp b/src/libtomahawk/playlist/XspfUpdater.cpp index 796efb17e..a9d794334 100644 --- a/src/libtomahawk/playlist/XspfUpdater.cpp +++ b/src/libtomahawk/playlist/XspfUpdater.cpp @@ -71,7 +71,11 @@ XspfUpdater::playlistLoaded() foreach ( const plentry_ptr ple, playlist()->entries() ) tracks << ple->query(); - QList< query_ptr > mergedTracks = TomahawkUtils::mergePlaylistChanges( tracks, loader->entries() ); + bool changed = false; + QList< query_ptr > mergedTracks = TomahawkUtils::mergePlaylistChanges( tracks, loader->entries(), changed ); + + if ( !changed ) + return; QList el = playlist()->entriesFromQueries( mergedTracks, true ); playlist()->createNewRevision( uuid(), playlist()->currentrevision(), el ); diff --git a/src/libtomahawk/playlist/customplaylistview.cpp b/src/libtomahawk/playlist/customplaylistview.cpp index 5e81cd6ca..b3b2c2ba5 100644 --- a/src/libtomahawk/playlist/customplaylistview.cpp +++ b/src/libtomahawk/playlist/customplaylistview.cpp @@ -104,7 +104,11 @@ CustomPlaylistView::generateTracks() void CustomPlaylistView::tracksGenerated( QList< query_ptr > tracks ) { - QList< query_ptr > newTracks = TomahawkUtils::mergePlaylistChanges( m_model->queries(), tracks ); + bool changed = false; + QList< query_ptr > newTracks = TomahawkUtils::mergePlaylistChanges( m_model->queries(), tracks, changed); + + if ( !changed ) + return; m_model->clear(); m_model->append( newTracks ); diff --git a/src/libtomahawk/utils/tomahawkutils.cpp b/src/libtomahawk/utils/tomahawkutils.cpp index 367164955..d706c3232 100644 --- a/src/libtomahawk/utils/tomahawkutils.cpp +++ b/src/libtomahawk/utils/tomahawkutils.cpp @@ -533,10 +533,12 @@ newerVersion( const QString& oldVersion, const QString& newVersion ) QList< Tomahawk::query_ptr > -mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tomahawk::query_ptr >& newTracks ) +mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tomahawk::query_ptr >& newTracks, bool& changed ) { int sameCount = 0; QList< Tomahawk::query_ptr > tosave = newTracks; + changed = false; + foreach ( const Tomahawk::query_ptr& newquery, newTracks ) { foreach ( const Tomahawk::query_ptr& oldq, orig ) @@ -558,6 +560,7 @@ mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tom if ( orig.size() == newTracks.size() && sameCount == orig.size() ) return orig; + changed = true; return tosave; } diff --git a/src/libtomahawk/utils/tomahawkutils.h b/src/libtomahawk/utils/tomahawkutils.h index 6c4b32dfa..f3133e112 100644 --- a/src/libtomahawk/utils/tomahawkutils.h +++ b/src/libtomahawk/utils/tomahawkutils.h @@ -110,7 +110,7 @@ namespace TomahawkUtils * * \return true if some changes were made, false if the new tracks are the same as the current tracks in \param orig */ - DLLEXPORT QList< Tomahawk::query_ptr > mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tomahawk::query_ptr >& newTracks ); + DLLEXPORT QList< Tomahawk::query_ptr > mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tomahawk::query_ptr >& newTracks, bool& changed ); DLLEXPORT void crash(); }