diff --git a/include/ProjectJournal.h b/include/ProjectJournal.h index 28beaa82ff7..93b5867eafe 100644 --- a/include/ProjectJournal.h +++ b/include/ProjectJournal.h @@ -76,6 +76,8 @@ class ProjectJournal reallocID( _id, NULL ); } + static jo_id_t idToSave( jo_id_t id ); + void clearJournal(); void stopAllJournalling(); JournallingObject * journallingObject( const jo_id_t _id ) diff --git a/include/ProjectNotes.h b/include/ProjectNotes.h index 998f47d996a..62446eb2258 100644 --- a/include/ProjectNotes.h +++ b/include/ProjectNotes.h @@ -29,7 +29,7 @@ #include #include -#include "JournallingObject.h" +#include "SerializingObject.h" class QAction; class QComboBox; diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index 077e68f94b1..90c07b9fb54 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -28,6 +28,7 @@ #include "ControllerConnection.h" #include "lmms_math.h" #include "Mixer.h" +#include "ProjectJournal.h" float AutomatableModel::s_copiedValue = 0; long AutomatableModel::s_periodCounter = 0; @@ -98,7 +99,7 @@ void AutomatableModel::saveSettings( QDomDocument& doc, QDomElement& element, co // scale type also needs an extra value // => it must be appended as a node QDomElement me = doc.createElement( name ); - me.setAttribute( "id", id() ); + me.setAttribute( "id", ProjectJournal::idToSave( id() ) ); me.setAttribute( "value", m_value ); me.setAttribute( "scale_type", m_scaleType == Logarithmic ? "log" : "linear" ); element.appendChild( me ); diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index 1ff07128c56..12db6dc2eb6 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -535,7 +535,8 @@ void AutomationPattern::saveSettings( QDomDocument & _doc, QDomElement & _this ) if( *it ) { QDomElement element = _doc.createElement( "object" ); - element.setAttribute( "id", ( *it )->id() ); + element.setAttribute( "id", + ProjectJournal::idToSave( ( *it )->id() ) ); _this.appendChild( element ); } } diff --git a/src/core/ProjectJournal.cpp b/src/core/ProjectJournal.cpp index 4e5c9229b42..bccb1520237 100644 --- a/src/core/ProjectJournal.cpp +++ b/src/core/ProjectJournal.cpp @@ -29,6 +29,8 @@ #include "JournallingObject.h" #include "Song.h" +static const int EO_ID_MSB = 1 << 23; + const int ProjectJournal::MAX_UNDO_STATES = 100; // TODO: make this configurable in settings ProjectJournal::ProjectJournal() : @@ -131,11 +133,9 @@ void ProjectJournal::addJournalCheckPoint( JournallingObject *jo ) jo_id_t ProjectJournal::allocID( JournallingObject * _obj ) { - const jo_id_t EO_ID_MAX = (1 << 23)-1; jo_id_t id; - while( m_joIDs.contains( id = - static_cast( (jo_id_t)rand()*(jo_id_t)rand() % - EO_ID_MAX ) ) ) + for( jo_id_t tid = rand(); m_joIDs.contains( id = tid % EO_ID_MSB + | EO_ID_MSB ); tid++ ) { } @@ -159,6 +159,14 @@ void ProjectJournal::reallocID( const jo_id_t _id, JournallingObject * _obj ) +jo_id_t ProjectJournal::idToSave( jo_id_t id ) +{ + return id & ~EO_ID_MSB; +} + + + + void ProjectJournal::clearJournal() { m_undoCheckPoints.clear();