diff --git a/src/libtomahawk/Album.cpp b/src/libtomahawk/Album.cpp index c719cf1da..35c3db7a9 100644 --- a/src/libtomahawk/Album.cpp +++ b/src/libtomahawk/Album.cpp @@ -164,15 +164,23 @@ Album::id() const if ( waiting ) { - finalId = m_idFuture.get(); + try + { + finalId = m_idFuture.get(); - s_idMutex.lockForWrite(); - m_id = finalId; - m_waitingForId = false; + s_idMutex.lockForWrite(); + m_id = finalId; + m_waitingForId = false; - if ( m_id > 0 ) - s_albumsById[ m_id ] = m_ownRef.toStrongRef(); - s_idMutex.unlock(); + if ( m_id > 0 ) + s_albumsById[ m_id ] = m_ownRef.toStrongRef(); + s_idMutex.unlock(); + } + catch( boost::future_uninitialized& e ) + { + qWarning() << "Caught boost::future_uninitialized when trying to get artist id from future, WTF?"; + qWarning() << "Potential race condition, do we have an ID?" << m_id << "and waiting?" << m_waitingForId << e.what(); + } } return finalId; diff --git a/src/libtomahawk/Artist.cpp b/src/libtomahawk/Artist.cpp index b58ce992f..aaca5b52d 100644 --- a/src/libtomahawk/Artist.cpp +++ b/src/libtomahawk/Artist.cpp @@ -244,15 +244,23 @@ Artist::id() const if ( waiting ) { - finalid = m_idFuture.get(); + try + { + finalid = m_idFuture.get(); - s_idMutex.lockForWrite(); - m_id = finalid; - m_waitingForFuture = false; + s_idMutex.lockForWrite(); + m_id = finalid; + m_waitingForFuture = false; - if ( m_id > 0 ) - s_artistsById[ m_id ] = m_ownRef.toStrongRef(); - s_idMutex.unlock(); + if ( m_id > 0 ) + s_artistsById[ m_id ] = m_ownRef.toStrongRef(); + s_idMutex.unlock(); + } + catch( boost::future_uninitialized& e ) + { + qWarning() << "Caught boost::future_uninitialized when trying to get artist id from future, WTF?"; + qWarning() << "Potential race condition, do we have an ID?" << m_id << "and waiting?" << m_waitingForFuture << e.what(); + } } return m_id;