diff --git a/src/accounts/spotify/SpotifyAccount.cpp b/src/accounts/spotify/SpotifyAccount.cpp index 7ff302c5f..c4cae8a3a 100644 --- a/src/accounts/spotify/SpotifyAccount.cpp +++ b/src/accounts/spotify/SpotifyAccount.cpp @@ -384,6 +384,13 @@ SpotifyAccount::registerUpdaterForPlaylist( const QString& plId, SpotifyPlaylist } +void +SpotifyAccount::unregisterUpdater( const QString& plid ) +{ + m_updaters.remove( plid ); +} + + void SpotifyAccount::fetchFullPlaylist( SpotifyPlaylistInfo* playlist ) { @@ -406,7 +413,7 @@ SpotifyAccount::stopPlaylistSync( SpotifyPlaylistInfo* playlist ) m_spotifyResolver.data()->sendMessage( msg ); - if ( deleteOnUnsync() ) + if ( deleteOnUnsync() && m_updaters.contains( playlist->plid ) ) { SpotifyPlaylistUpdater* updater = m_updaters.take( playlist->plid ); playlist_ptr tomahawkPl = updater->playlist(); diff --git a/src/accounts/spotify/SpotifyAccount.h b/src/accounts/spotify/SpotifyAccount.h index d77757f64..4a71b1a29 100644 --- a/src/accounts/spotify/SpotifyAccount.h +++ b/src/accounts/spotify/SpotifyAccount.h @@ -86,7 +86,9 @@ public: virtual SipPlugin* sipPlugin() { return 0; } void sendMessage( const QVariantMap& msg, QObject* receiver, const QString& slot ); + void registerUpdaterForPlaylist( const QString& plId, SpotifyPlaylistUpdater* updater ); + void unregisterUpdater( const QString& plid ); bool deleteOnUnsync() const; private slots: diff --git a/src/accounts/spotify/SpotifyPlaylistUpdater.cpp b/src/accounts/spotify/SpotifyPlaylistUpdater.cpp index c59a61133..a30b64c69 100644 --- a/src/accounts/spotify/SpotifyPlaylistUpdater.cpp +++ b/src/accounts/spotify/SpotifyPlaylistUpdater.cpp @@ -85,7 +85,10 @@ SpotifyPlaylistUpdater::init() SpotifyPlaylistUpdater::~SpotifyPlaylistUpdater() { - + if ( !m_spotify.isNull() ) + { + m_spotify.data()->unregisterUpdater( m_spotifyId ); + } }