SyncEngine: Avoid transaction warning

This commit is contained in:
Markus Goetz 2014-10-20 17:20:58 +02:00
parent 04b62b139d
commit 2de22b408b
3 changed files with 12 additions and 1 deletions

View file

@ -618,7 +618,7 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
return;
} else {
// Commits a possibly existing (should not though) transaction and starts a new one for the propagate phase
_journal->commit("pre Propagate");
_journal->commitIfNeededAndStartNewTransaction("Post discovery");
}
if( csync_reconcile(_csync_ctx) < 0 ) {

View file

@ -1046,6 +1046,16 @@ void SyncJournalDb::commit(const QString& context, bool startTrans)
commitInternal(context, startTrans);
}
void SyncJournalDb::commitIfNeededAndStartNewTransaction(const QString &context)
{
QMutexLocker lock(&_mutex);
if( _transaction == 1 ) {
commitInternal(context, true);
} else {
startTransaction();
}
}
void SyncJournalDb::commitInternal(const QString& context, bool startTrans )
{

View file

@ -93,6 +93,7 @@ public:
* Commit will actually commit the transaction and create a new one.
*/
void commit(const QString &context, bool startTrans = true);
void commitIfNeededAndStartNewTransaction(const QString &context);
void close();