Skip to content

Commit 8ddc270

Browse files
committed
Workaround crash from SpotifyParser
1 parent 47e09fb commit 8ddc270

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/libtomahawk/accounts/spotify/SpotifyAccount.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,15 +842,28 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
842842
const QString qid = msg.value( "qid" ).toString();
843843
if ( m_qidToSlotMap.contains( qid ) )
844844
{
845-
QObject* receiver = m_qidToSlotMap[ qid ].first;
845+
QPointer< QObject > receiver = m_qidToSlotMap[ qid ].first;
846846
QString slot = m_qidToSlotMap[ qid ].second;
847847
m_qidToSlotMap.remove( qid );
848848

849+
849850
QVariant extraData;
850851
if ( m_qidToExtraData.contains( qid ) )
851852
extraData = m_qidToExtraData.take( qid );
852853

853-
QMetaObject::invokeMethod( receiver, slot.toLatin1(), Q_ARG( QString, msgType ), Q_ARG( QVariantMap, msg ), Q_ARG( QVariant, extraData ) );
854+
// 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
855+
//Q_ASSERT( !receiver.isNull() );
856+
857+
if ( !receiver.isNull() )
858+
{
859+
QMetaObject::invokeMethod( receiver, slot.toLatin1(), Q_ARG( QString, msgType ), Q_ARG( QVariantMap, msg ), Q_ARG( QVariant, extraData ) );
860+
}
861+
else
862+
{
863+
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage(
864+
tr( "Spotify account could not finish action. Try again." )
865+
) );
866+
}
854867
}
855868
else if ( msgType == "allPlaylists" )
856869
{

src/libtomahawk/accounts/spotify/SpotifyAccount.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private slots:
172172
QPointer<ScriptResolver> m_spotifyResolver;
173173
QPointer< InfoSystem::SpotifyInfoPlugin > m_infoPlugin;
174174

175-
QMap<QString, QPair<QObject*, QString> > m_qidToSlotMap;
175+
QMap<QString, QPair< QPointer< QObject >, QString> > m_qidToSlotMap;
176176
QMap<QString, QVariant > m_qidToExtraData;
177177

178178
// List of synced spotify playlists in config UI

0 commit comments

Comments
 (0)