]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
fix p1: full sync bug & mutex
authorgg <chown_tee@proton.me>
Mon, 12 Jan 2026 13:58:23 +0000 (08:58 -0500)
committergg <chown_tee@proton.me>
Mon, 12 Jan 2026 13:58:23 +0000 (08:58 -0500)
src/WindowManager.cpp
src/libwalletqt/Wallet.cpp

index b0e50ec28a39072e3063494863772b3c2babe742..69d81198c5f6c2690af7da2ad9176b5ac4b03d1b 100644 (file)
@@ -106,7 +106,7 @@ void WindowManager::close() {
 
     // Wait for all threads in the global thread pool with timeout to prevent indefinite blocking
     if (!QThreadPool::globalInstance()->waitForDone(15000)) {
-        qCritical() << "WindowManager: Thread pool tasks did not complete within 30s timeout. "
+        qCritical() << "WindowManager: Thread pool tasks did not complete within 15s timeout. "
                     << "Forcing exit to prevent use-after-free.";
         std::_Exit(1);  // Fast exit without cleanup - threads may still hold resources
     }
index 4c079f425e62218a12909856cab76d7cf359cb9c..f43605e89eb8682e83282427c2d7afcde5ec49b5 100644 (file)
@@ -574,6 +574,7 @@ void Wallet::skipToTip() {
         return;
     uint64_t tip = m_wallet2->get_blockchain_current_height();
     if (tip > 0) {
+        QMutexLocker locker(&m_asyncMutex);
         // Log previous height for debugging
         uint64_t prevHeight = m_wallet2->get_refresh_from_block_height();
         qInfo() << "Skip Sync triggered. Head moving from" << prevHeight << "to:" << tip;
@@ -599,10 +600,12 @@ void Wallet::syncDateRange(const QDate &start, const QDate &end) {
     if (startHeight >= endHeight)
         return;
 
-    m_stopHeight = endHeight;
-    m_rangeSyncActive = true;
-
-    m_wallet2->set_refresh_from_block_height(startHeight);
+    {
+        QMutexLocker locker(&m_asyncMutex);
+        m_stopHeight = endHeight;
+        m_rangeSyncActive = true;
+        m_wallet2->set_refresh_from_block_height(startHeight);
+    }
     pauseRefresh();
     startRefresh();
 }
@@ -627,13 +630,12 @@ void Wallet::fullSync() {
                    << ". This may miss transactions if skipToTip() was previously used.";
     }
 
-    m_wallet2->set_refresh_from_block_height(originalHeight);
+    {
+        QMutexLocker locker(&m_asyncMutex);
+        m_wallet2->set_refresh_from_block_height(originalHeight);
+    }
     // Trigger rescan
     pauseRefresh();
-
-    // Optional: Clear transaction cache to ensure fresh view
-    // m_wallet2->clearCache();
-
     startRefresh();
 
     qInfo() << "Full Sync triggered. Rescanning from original restore height:" << originalHeight;