From df86b4c81e2bfa66088dc49f47c9a8d0c9c0048c Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 4 Aug 2008 17:58:15 +0000 Subject: [PATCH] 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 --- src/core/project_journal.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/project_journal.cpp b/src/core/project_journal.cpp index 4f03fd3a9..3d4a9ce9b 100644 --- a/src/core/project_journal.cpp +++ b/src/core/project_journal.cpp @@ -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( (float) rand() / - RAND_MAX * EO_ID_MAX ) ) ) + while( m_joIDs.contains( id = static_cast( rand() % + EO_ID_MAX ) ) ) { } + m_joIDs[id] = _obj; //printf("new id: %d\n", id ); return( id );