From c3c550139689f5e973396716d09e7a1c4a901c9d Mon Sep 17 00:00:00 2001 From: "Raine M. Ekman" Date: Mon, 1 Dec 2014 21:28:29 +0200 Subject: [PATCH] Master kill switch for journalling, useful when closing program. --- include/ProjectJournal.h | 2 +- src/core/JournallingObject.cpp | 17 +++++++++++------ src/core/ProjectJournal.cpp | 12 ++++++++++++ src/core/engine.cpp | 1 + 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/include/ProjectJournal.h b/include/ProjectJournal.h index 20ff70959..5cb7920f6 100644 --- a/include/ProjectJournal.h +++ b/include/ProjectJournal.h @@ -74,7 +74,7 @@ public: } void clearJournal(); - + void stopAllJournalling(); JournallingObject * journallingObject( const jo_id_t _id ) { if( m_joIDs.contains( _id ) ) diff --git a/src/core/JournallingObject.cpp b/src/core/JournallingObject.cpp index 4e5b20aad..90d597365 100644 --- a/src/core/JournallingObject.cpp +++ b/src/core/JournallingObject.cpp @@ -70,14 +70,19 @@ void JournallingObject::addJournalCheckPoint() QDomElement JournallingObject::saveState( QDomDocument & _doc, QDomElement & _parent ) { - QDomElement _this = SerializingObject::saveState( _doc, _parent ); + if( isJournalling() ) + { + QDomElement _this = SerializingObject::saveState( _doc, _parent ); - QDomElement journalNode = _doc.createElement( "journallingObject" ); - journalNode.setAttribute( "id", id() ); - journalNode.setAttribute( "metadata", true ); - _this.appendChild( journalNode ); + QDomElement journalNode = _doc.createElement( "journallingObject" ); + journalNode.setAttribute( "id", id() ); + journalNode.setAttribute( "metadata", true ); + _this.appendChild( journalNode ); - return _this; + return _this; + } else { + return QDomElement(); + } } diff --git a/src/core/ProjectJournal.cpp b/src/core/ProjectJournal.cpp index c04f81d26..511df4059 100644 --- a/src/core/ProjectJournal.cpp +++ b/src/core/ProjectJournal.cpp @@ -168,5 +168,17 @@ void ProjectJournal::clearJournal() } } +void ProjectJournal::stopAllJournalling() +{ + for( JoIdMap::Iterator it = m_joIDs.begin(); it != m_joIDs.end(); ++it) + { + if( it.value() != NULL ) + { + it.value()->setJournalling(false); + } + } + setJournalling(false); +} + diff --git a/src/core/engine.cpp b/src/core/engine.cpp index 4931b571d..f7864e46f 100644 --- a/src/core/engine.cpp +++ b/src/core/engine.cpp @@ -115,6 +115,7 @@ void engine::init( const bool _has_gui ) void engine::destroy() { + s_projectJournal->stopAllJournalling(); s_mixer->stopProcessing(); deleteHelper( &s_projectNotes );