mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-13 20:39:57 +01:00
some safety
This commit is contained in:
parent
22e53172eb
commit
e147bf4861
@ -40,7 +40,7 @@ SpotifyUpdaterFactory::create( const Tomahawk::playlist_ptr& pl )
|
||||
}
|
||||
}
|
||||
|
||||
if ( !m_account )
|
||||
if ( m_account.isNull() )
|
||||
{
|
||||
qWarning() << "Found a spotify updater with no spotify account... ignoreing for now!!";
|
||||
return 0;
|
||||
@ -49,8 +49,8 @@ SpotifyUpdaterFactory::create( const Tomahawk::playlist_ptr& pl )
|
||||
// Register the updater with the account
|
||||
const QString spotifyId = TomahawkSettings::instance()->value( QString( "playlistupdaters/%1/spotifyId" ).arg( pl->guid() ) ).toString();
|
||||
Q_ASSERT( !spotifyId.isEmpty() );
|
||||
SpotifyPlaylistUpdater* updater = new SpotifyPlaylistUpdater( m_account, pl );
|
||||
m_account->registerUpdaterForPlaylist( spotifyId, updater );
|
||||
SpotifyPlaylistUpdater* updater = new SpotifyPlaylistUpdater( m_account.data(), pl );
|
||||
m_account.data()->registerUpdaterForPlaylist( spotifyId, updater );
|
||||
|
||||
return updater;
|
||||
}
|
||||
@ -232,6 +232,9 @@ SpotifyPlaylistUpdater::spotifyTracksMoved( const QVariantList& tracks, const QS
|
||||
void
|
||||
SpotifyPlaylistUpdater::tomahawkTracksInserted( const QList< plentry_ptr >& tracks, int pos )
|
||||
{
|
||||
if ( m_spotify.isNull() )
|
||||
return;
|
||||
|
||||
if ( m_blockUpdatesForNextRevision )
|
||||
{
|
||||
qDebug() << "Ignoring tracks inserted message since we just did an insert ourselves!";
|
||||
@ -276,7 +279,7 @@ SpotifyPlaylistUpdater::tomahawkTracksInserted( const QList< plentry_ptr >& trac
|
||||
}
|
||||
msg[ "tracks" ] = tracksJson;
|
||||
|
||||
m_spotify->sendMessage( msg, this, "onTracksInsertedReturn" );
|
||||
m_spotify.data()->sendMessage( msg, this, "onTracksInsertedReturn" );
|
||||
}
|
||||
|
||||
|
||||
@ -340,6 +343,9 @@ SpotifyPlaylistUpdater::onTracksInsertedReturn( const QString& msgType, const QV
|
||||
void
|
||||
SpotifyPlaylistUpdater::tomahawkTracksRemoved( const QList< query_ptr >& tracks )
|
||||
{
|
||||
if ( m_spotify.isNull() )
|
||||
return;
|
||||
|
||||
if ( m_blockUpdatesForNextRevision )
|
||||
{
|
||||
qDebug() << "Ignoring tracks removed message since we just did a remove ourselves!";
|
||||
@ -354,7 +360,7 @@ SpotifyPlaylistUpdater::tomahawkTracksRemoved( const QList< query_ptr >& tracks
|
||||
msg[ "oldrev" ] = m_latestRev;
|
||||
msg[ "tracks" ] = queriesToVariant( tracks );
|
||||
|
||||
m_spotify->sendMessage( msg, this, "onTracksRemovedReturn" );
|
||||
m_spotify.data()->sendMessage( msg, this, "onTracksRemovedReturn" );
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,7 +73,7 @@ private:
|
||||
static QVariant queryToVariant( const Tomahawk::query_ptr& query );
|
||||
static QList< Tomahawk::query_ptr > variantToQueries( const QVariantList& list );
|
||||
|
||||
Tomahawk::Accounts::SpotifyAccount* m_spotify;
|
||||
QWeakPointer<Tomahawk::Accounts::SpotifyAccount> m_spotify;
|
||||
QString m_latestRev, m_spotifyId;
|
||||
QList< Tomahawk::plentry_ptr > m_waitingForIds;
|
||||
|
||||
@ -85,13 +85,13 @@ private:
|
||||
class SpotifyUpdaterFactory : public Tomahawk::PlaylistUpdaterFactory
|
||||
{
|
||||
public:
|
||||
SpotifyUpdaterFactory() : m_account( 0 ) {}
|
||||
SpotifyUpdaterFactory() {}
|
||||
|
||||
virtual Tomahawk::PlaylistUpdaterInterface* create( const Tomahawk::playlist_ptr& pl );
|
||||
virtual QString type() const { return "spotify"; }
|
||||
|
||||
private:
|
||||
Tomahawk::Accounts::SpotifyAccount* m_account;
|
||||
QWeakPointer<Tomahawk::Accounts::SpotifyAccount> m_account;
|
||||
};
|
||||
|
||||
#endif // SPOTIFYPLAYLISTUPDATER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user