// 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
}
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;
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();
}
<< ". 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;