1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 14:16:32 +02: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

@@ -163,6 +163,8 @@ Album::id() const
s_idMutex.unlock(); s_idMutex.unlock();
if ( waiting ) if ( waiting )
{
try
{ {
finalId = m_idFuture.get(); finalId = m_idFuture.get();
@@ -174,6 +176,12 @@ Album::id() const
s_albumsById[ m_id ] = m_ownRef.toStrongRef(); s_albumsById[ m_id ] = m_ownRef.toStrongRef();
s_idMutex.unlock(); 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; return finalId;
} }

View File

@@ -243,6 +243,8 @@ Artist::id() const
s_idMutex.unlock(); s_idMutex.unlock();
if ( waiting ) if ( waiting )
{
try
{ {
finalid = m_idFuture.get(); finalid = m_idFuture.get();
@@ -254,6 +256,12 @@ Artist::id() const
s_artistsById[ m_id ] = m_ownRef.toStrongRef(); s_artistsById[ m_id ] = m_ownRef.toStrongRef();
s_idMutex.unlock(); 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; return m_id;
} }