From: gg Date: Mon, 12 Jan 2026 13:58:23 +0000 (-0500) Subject: fix p1: full sync bug & mutex X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=8b90b3c9133aacad2d6789fc7e59bbe9ebebc09f;p=gamesguru%2Ffeather.git fix p1: full sync bug & mutex --- diff --git a/src/WindowManager.cpp b/src/WindowManager.cpp index b0e50ec2..69d81198 100644 --- a/src/WindowManager.cpp +++ b/src/WindowManager.cpp @@ -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 } diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 4c079f42..f43605e8 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -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;