Fix SyncEngineTest failure when localstate is destroyed.
authoralex-z <blackslayer4@gmail.com>
Tue, 13 Dec 2022 13:41:07 +0000 (14:41 +0100)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Thu, 15 Dec 2022 09:32:10 +0000 (10:32 +0100)
Signed-off-by: alex-z <blackslayer4@gmail.com>
test/testsyncengine.cpp

index f3fdd704ea1ce9932efca4e20b3ffda854c007e9..03f470c936c35de29aab1761b0aa3fe43a38508d 100644 (file)
@@ -1256,9 +1256,11 @@ private slots:
 
         fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::DatabaseAndFilesystem);
         QVERIFY(fakeFolder.syncOnce());
-        QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
+        auto localState = fakeFolder.currentLocalState();
+        QCOMPARE(localState, fakeFolder.currentRemoteState());
         QCOMPARE(printDbData(fakeFolder.dbState()), printDbData(fakeFolder.currentRemoteState()));
-        const auto fileFirstSync = fakeFolder.currentLocalState().find(testFile);
+        const auto fileFirstSync = localState.find(testFile);
+
         QVERIFY(fileFirstSync);
         QCOMPARE(fileFirstSync->lastModified.toSecsSinceEpoch(), CURRENT_MTIME - 2);
 
@@ -1266,9 +1268,10 @@ private slots:
 
         fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::FilesystemOnly);
         QVERIFY(fakeFolder.syncOnce());
+        localState = fakeFolder.currentLocalState();
         QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
         QCOMPARE(printDbData(fakeFolder.dbState()), printDbData(fakeFolder.currentRemoteState()));
-        const auto fileSecondSync = fakeFolder.currentLocalState().find(testFile);
+        const auto fileSecondSync = localState.find(testFile);
         QVERIFY(fileSecondSync);
         QCOMPARE(fileSecondSync->lastModified.toSecsSinceEpoch(), CURRENT_MTIME - 1);
 
@@ -1276,9 +1279,10 @@ private slots:
 
         fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::FilesystemOnly);
         QVERIFY(fakeFolder.syncOnce());
-        QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
+        localState = fakeFolder.currentLocalState();
+        QCOMPARE(localState, fakeFolder.currentRemoteState());
         QCOMPARE(printDbData(fakeFolder.dbState()), printDbData(fakeFolder.currentRemoteState()));
-        const auto fileThirdSync = fakeFolder.currentLocalState().find(testFile);
+        const auto fileThirdSync = localState.find(testFile);
         QVERIFY(fileThirdSync);
         QCOMPARE(fileThirdSync->lastModified.toSecsSinceEpoch(), CURRENT_MTIME);
     }