use random-number-generator correctly - fixes predictable random numbers and avoids used Journalling-Object-IDs upon loading project (closes #2036745) - anyways this still might happen under rare circumstances and needs a further fix

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1432 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-08-04 17:58:15 +00:00
parent 6f05b70b5f
commit df86b4c81e

View File

@@ -107,10 +107,11 @@ jo_id_t projectJournal::allocID( journallingObject * _obj )
{
const jo_id_t EO_ID_MAX = 1 << 24;
jo_id_t id;
while( m_joIDs.contains( id = static_cast<jo_id_t>( (float) rand() /
RAND_MAX * EO_ID_MAX ) ) )
while( m_joIDs.contains( id = static_cast<jo_id_t>( rand() %
EO_ID_MAX ) ) )
{
}
m_joIDs[id] = _obj;
//printf("new id: %d\n", id );
return( id );