1919#include " account.h"
2020#include " accountstate.h"
2121#include " application.h"
22- #include " common/checksums.h"
2322#include " common/depreaction.h"
2423#include " common/filesystembase.h"
2524#include " common/syncjournalfilerecord.h"
5554#include < QTimer>
5655#include < QUrl>
5756
58- #include < QApplication>
59- #include < QMessageBox>
60-
6157using namespace Qt ::Literals::StringLiterals;
6258using namespace std ::chrono_literals;
6359
@@ -85,7 +81,9 @@ Folder::Folder(const FolderDefinition &definition, const AccountStatePtr &accoun
8581 _timeSinceLastSyncStart.start ();
8682 _timeSinceLastSyncDone.start ();
8783
88- setSyncState (definition.paused ? SyncResult::Paused : SyncResult::Queued);
84+ // set the sync state without emiting a signal
85+ _syncResult.setStatus (definition.paused ? SyncResult::Paused : SyncResult::Queued);
86+
8987 // check if the local path exists
9088 if (checkLocalPath ()) {
9189 // those errors should not persist over sessions
@@ -100,7 +98,8 @@ Folder::Folder(const FolderDefinition &definition, const AccountStatePtr &accoun
10098
10199 connect (_accountState.data (), &AccountState::isConnectedChanged, this , &Folder::canSyncChanged);
102100
103- connect (_engine.data (), &SyncEngine::finished, this , &Folder::slotSyncFinished);
101+ // use a direct connection, the folder status has to be up to date
102+ connect (_engine.data (), &SyncEngine::finished, this , &Folder::slotSyncFinished, Qt::DirectConnection);
104103
105104 connect (_engine.data (), &SyncEngine::transmissionProgress, this ,
106105 [this ](const ProgressInfo &pi) { Q_EMIT ProgressDispatcher::instance ()->progressInfo (this , pi); });
@@ -398,8 +397,8 @@ void Folder::setSyncState(SyncResult::Status state)
398397{
399398 const auto oldIsRunning = isSyncRunning ();
400399 if (state != _syncResult.status ()) {
400+ qCDebug (lcFolder) << u" State of" << path () << u" changed to" << state << u" old state" << _syncResult.status ();
401401 _syncResult.setStatus (state);
402- qCDebug (lcFolder) << u" State of" << path () << u" changed to" << state;
403402 Q_EMIT syncStateChange ();
404403 if (oldIsRunning != isSyncRunning ()) {
405404 Q_EMIT isSyncRunningChanged ();
@@ -882,9 +881,7 @@ void Folder::startSync()
882881 }
883882
884883 _engine->setIgnoreHiddenFiles (_definition.ignoreHiddenFiles );
885- QMetaObject::invokeMethod (_engine.data (), &SyncEngine::startSync, Qt::QueuedConnection);
886-
887- Q_EMIT syncStarted ();
884+ _engine->startSync ();
888885}
889886
890887void Folder::setDirtyNetworkLimits ()
@@ -936,7 +933,6 @@ void Folder::slotSyncFinished(bool success)
936933 qCInfo (lcFolder) << u" SyncEngine finished without problem." ;
937934 }
938935 _fileLog->finish ();
939- showSyncResultPopup ();
940936
941937 auto anotherSyncNeeded = false ;
942938
@@ -975,10 +971,10 @@ void Folder::slotSyncFinished(bool success)
975971
976972 if (syncStatus != SyncResult::Undefined) {
977973 setSyncState (syncStatus);
974+ showSyncResultPopup ();
978975 }
979976
980- // syncStateChange from setSyncState needs to be emitted first
981- QTimer::singleShot (0 , this , [this ] { Q_EMIT syncFinished (_syncResult); });
977+ Q_EMIT syncFinished (_syncResult);
982978
983979 _lastSyncDuration = std::chrono::milliseconds (_timeSinceLastSyncStart.elapsed ());
984980 _timeSinceLastSyncDone.start ();
0 commit comments