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:
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user