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