Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/ProjectJournal.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ProjectJournal
reallocID( _id, NULL );
}

static jo_id_t idToSave( jo_id_t id );
void changeID(const jo_id_t oldID, const jo_id_t newID);

void clearJournal();
void stopAllJournalling();
Expand Down
3 changes: 1 addition & 2 deletions src/core/AutomatableModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "AutomationPattern.h"
#include "ControllerConnection.h"
#include "Mixer.h"
#include "ProjectJournal.h"

float AutomatableModel::s_copiedValue = 0;
long AutomatableModel::s_periodCounter = 0;
Expand Down Expand Up @@ -99,7 +98,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", ProjectJournal::idToSave( id() ) );
me.setAttribute( "id", id() );
me.setAttribute( "value", m_value );
me.setAttribute( "scale_type", m_scaleType == Logarithmic ? "log" : "linear" );
element.appendChild( me );
Expand Down
3 changes: 1 addition & 2 deletions src/core/AutomationPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,7 @@ void AutomationPattern::saveSettings( QDomDocument & _doc, QDomElement & _this )
if( *it )
{
QDomElement element = _doc.createElement( "object" );
element.setAttribute( "id",
ProjectJournal::idToSave( ( *it )->id() ) );
element.setAttribute( "id", ( *it )->id() );
_this.appendChild( element );
}
}
Expand Down
14 changes: 3 additions & 11 deletions src/core/JournallingObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,15 @@ void JournallingObject::changeID( jo_id_t _id )
{
JournallingObject * jo = Engine::projectJournal()->
journallingObject( _id );
// Fix ID collision
if( jo != NULL )
{
QString used_by = jo->nodeName();
if( used_by == "automatablemodel" &&
dynamic_cast<AutomatableModel *>( jo ) )
{
used_by += ":" +
dynamic_cast<AutomatableModel *>( jo )->
displayName();
}
fprintf( stderr, "JO-ID %d already in use by %s!\n",
(int) _id, used_by.toUtf8().constData() );
return;
jo->changeID( Engine::projectJournal()->allocID( NULL ) );
}

Engine::projectJournal()->freeID( m_id );
Engine::projectJournal()->reallocID( _id, this );
Engine::projectJournal()->changeID( m_id, _id );
m_id = _id;
}
}
Expand Down
20 changes: 8 additions & 12 deletions src/core/ProjectJournal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,7 @@ void ProjectJournal::addJournalCheckPoint( JournallingObject *jo )
jo_id_t ProjectJournal::allocID( JournallingObject * _obj )
{
jo_id_t id;
for( jo_id_t tid = rand(); m_joIDs.contains( id = tid % EO_ID_MSB
| EO_ID_MSB ); tid++ )
{
}
for(jo_id_t tid = rand(); m_joIDs.contains(id = tid & (EO_ID_MSB - 1)); ++tid);

m_joIDs[id] = _obj;
//printf("new id: %d\n", id );
Expand All @@ -156,17 +153,16 @@ void ProjectJournal::reallocID( const jo_id_t _id, JournallingObject * _obj )
}
}




jo_id_t ProjectJournal::idToSave( jo_id_t id )
void ProjectJournal::changeID(const jo_id_t oldID, const jo_id_t newID)
{
return id & ~EO_ID_MSB;
auto changeFunc = [oldID, newID](CheckPoint& c)
{
if (c.joID == oldID) {c.joID = newID;}
};
std::for_each(m_undoCheckPoints.begin(), m_undoCheckPoints.end(), changeFunc);
std::for_each(m_redoCheckPoints.begin(), m_redoCheckPoints.end(), changeFunc);
}




void ProjectJournal::clearJournal()
{
m_undoCheckPoints.clear();
Expand Down