1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 15:59:42 +01:00

Catch boost::unitialized_future if it is thrown

This commit is contained in:
Leo Franchi 2012-06-17 13:38:21 +02:00
parent ee8d3e6a92
commit c1d678e2b1
2 changed files with 30 additions and 14 deletions

View File

@ -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;

View File

@ -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;