[Pkg-owncloud-commits] [owncloud-client] 08/83: Always wait on the thread before emiting finished
Sandro Knauß
hefee-guest at moszumanska.debian.org
Sat May 31 11:31:37 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit bdba56f60b4d197fb3a38709e02bc0abe5bc4375
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Tue May 20 12:28:55 2014 +0200
Always wait on the thread before emiting finished
This ensure that there would be no way to have two thread running
Refactor all the location where finished is called in a single function
---
src/mirall/syncengine.cpp | 30 +++++++++++-------------------
src/mirall/syncengine.h | 3 +++
2 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp
index 9ff67e1..035843f 100644
--- a/src/mirall/syncengine.cpp
+++ b/src/mirall/syncengine.cpp
@@ -66,6 +66,7 @@ SyncEngine::SyncEngine(CSYNC *ctx, const QString& localPath, const QString& remo
qRegisterMetaType<SyncFileItem::Status>("SyncFileItem::Status");
qRegisterMetaType<Progress::Info>("Progress::Info");
+ _thread.setObjectName("CSync_Neon_Thread");
_thread.start();
}
@@ -414,10 +415,7 @@ void SyncEngine::handleSyncError(CSYNC *ctx, const char *state) {
} else {
emit csyncError(errStr);
}
- csync_commit(_csync_ctx);
- emit finished();
- _syncMutex.unlock();
- _thread.quit();
+ finalize();
}
void SyncEngine::startSync()
@@ -451,12 +449,7 @@ void SyncEngine::startSync()
if( fileRecordCount == -1 ) {
qDebug() << "No way to create a sync journal!";
emit csyncError(tr("Unable to initialize a sync journal."));
-
- csync_commit(_csync_ctx);
- emit finished();
- _syncMutex.unlock();
- _thread.quit();
-
+ finalize();
return;
// database creation error!
} else if ( fileRecordCount < 50 ) {
@@ -553,10 +546,7 @@ void SyncEngine::slotUpdateFinished(int updateResult)
if (!_journal->isConnected()) {
qDebug() << "Bailing out, DB failure";
emit csyncError(tr("Cannot open the sync journal"));
- csync_commit(_csync_ctx);
- emit finished();
- _syncMutex.unlock();
- _thread.quit();
+ finalize();
return;
}
@@ -570,10 +560,7 @@ void SyncEngine::slotUpdateFinished(int updateResult)
emit aboutToRemoveAllFiles(_syncedItems.first()._direction, &cancel);
if (cancel) {
qDebug() << Q_FUNC_INFO << "Abort sync";
- csync_commit(_csync_ctx);
- emit finished();
- _syncMutex.unlock();
- _thread.quit();
+ finalize();
return;
}
}
@@ -673,16 +660,21 @@ void SyncEngine::slotFinished()
}
_journal->commit("All Finished.", false);
emit treeWalkResult(_syncedItems);
+ finalize();
+}
+void SyncEngine::finalize()
+{
csync_commit(_csync_ctx);
qDebug() << "CSync run took " << _stopWatch.addLapTime(QLatin1String("Sync Finished"));
_stopWatch.stop();
- emit finished();
_propagator.reset(0);
_syncMutex.unlock();
_thread.quit();
+ _thread.wait();
+ emit finished();
}
void SyncEngine::slotProgress(const SyncFileItem& item, quint64 current)
diff --git a/src/mirall/syncengine.h b/src/mirall/syncengine.h
index c38e793..c1034bd 100644
--- a/src/mirall/syncengine.h
+++ b/src/mirall/syncengine.h
@@ -101,6 +101,9 @@ private:
int treewalkFile( TREE_WALK_FILE*, bool );
bool checkBlacklisting( SyncFileItem *item );
+ // cleanup and emit the finished signal
+ void finalize();
+
static QMutex _syncMutex;
SyncFileItemVector _syncedItems;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list