Skip to content

Commit

Permalink
Workaround crash from SpotifyParser
Browse files Browse the repository at this point in the history
  • Loading branch information
dschmidt committed Jan 13, 2016
1 parent 47e09fb commit 9c258ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/libtomahawk/accounts/spotify/SpotifyAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,15 +842,28 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
const QString qid = msg.value( "qid" ).toString();
if ( m_qidToSlotMap.contains( qid ) )
{
QObject* receiver = m_qidToSlotMap[ qid ].first;
QPointer< QObject > receiver = m_qidToSlotMap[ qid ].first;
QString slot = m_qidToSlotMap[ qid ].second;
m_qidToSlotMap.remove( qid );


QVariant extraData;
if ( m_qidToExtraData.contains( qid ) )
extraData = m_qidToExtraData.take( qid );

QMetaObject::invokeMethod( receiver, slot.toLatin1(), Q_ARG( QString, msgType ), Q_ARG( QVariantMap, msg ), Q_ARG( QVariant, extraData ) );
// FIXME: SpotifyParser is sometimes a dangling pointer, haven't found a real way to reproduce: happens sometimes when dropping a playlist url onto the sidebar
//Q_ASSERT( !receiver.isNull() );

if ( !receiver.isNull() )
{
QMetaObject::invokeMethod( receiver, slot.toLatin1(), Q_ARG( QString, msgType ), Q_ARG( QVariantMap, msg ), Q_ARG( QVariant, extraData ) );
}
else
{
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage(
tr( "Spotify account could not finish action. Try again.n" )
) );
}
}
else if ( msgType == "allPlaylists" )
{
Expand Down
2 changes: 1 addition & 1 deletion src/libtomahawk/accounts/spotify/SpotifyAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private slots:
QPointer<ScriptResolver> m_spotifyResolver;
QPointer< InfoSystem::SpotifyInfoPlugin > m_infoPlugin;

QMap<QString, QPair<QObject*, QString> > m_qidToSlotMap;
QMap<QString, QPair< QPointer< QObject >, QString> > m_qidToSlotMap;
QMap<QString, QVariant > m_qidToExtraData;

// List of synced spotify playlists in config UI
Expand Down

0 comments on commit 9c258ef

Please sign in to comment.