From ff44238d066f7da18c8a239e29a00bcc4011ba5d Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sat, 14 Jul 2012 14:02:59 +0200 Subject: [PATCH] * Lock mutex when adding to the static hashes in Artist and Album. --- src/libtomahawk/Album.cpp | 5 ++++- src/libtomahawk/Artist.cpp | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/Album.cpp b/src/libtomahawk/Album.cpp index 89b46eef5..c2a9bac87 100644 --- a/src/libtomahawk/Album.cpp +++ b/src/libtomahawk/Album.cpp @@ -201,9 +201,12 @@ Album::id() const m_waitingForId = false; if ( m_id > 0 ) + { + QMutexLocker lock( &s_mutex ); s_albumsById[ m_id ] = m_ownRef.toStrongRef(); - s_idMutex.unlock(); + } + s_idMutex.unlock(); } return finalId; diff --git a/src/libtomahawk/Artist.cpp b/src/libtomahawk/Artist.cpp index 03deda53e..29c279ffe 100644 --- a/src/libtomahawk/Artist.cpp +++ b/src/libtomahawk/Artist.cpp @@ -280,7 +280,11 @@ Artist::id() const m_waitingForFuture = false; if ( m_id > 0 ) + { + QMutexLocker lock( &s_mutex ); s_artistsById[ m_id ] = m_ownRef.toStrongRef(); + } + s_idMutex.unlock(); }