From: gg Date: Mon, 12 Jan 2026 13:24:03 +0000 (-0500) Subject: resolve build errors & lint warnings X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=28a2f6d8f96e52ce48431ad287fa39386785f7e8;p=gamesguru%2Ffeather.git resolve build errors & lint warnings --- diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index d15bf349..9282db96 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -277,14 +277,8 @@ void MainWindow::initStatusBar() { auto *fromDateEdit = new QDateEdit(QDate::currentDate().addDays(-defaultDays)); fromDateEdit->setCalendarPopup(true); fromDateEdit->setDisplayFormat("yyyy-MM-dd"); - fromDateEdit->setCalendarPopup(true); - fromDateEdit->setDisplayFormat("yyyy-MM-dd"); fromDateEdit->setToolTip(tr("Calculated from 'End date' and day span.")); - - toDateEdit->setCalendarPopup(true); - toDateEdit->setDisplayFormat("yyyy-MM-dd"); - auto *infoLabel = new QLabel; infoLabel->setWordWrap(true); infoLabel->setStyleSheet("QLabel { color: #888; font-size: 11px; }"); @@ -994,17 +988,19 @@ void MainWindow::onSyncStatus(quint64 height, quint64 target, bool daemonSync) { } else { // Calculate depth quint64 blocksLeft = (target > height) ? (target - height) : 0; - // Estimate download size in MB: assuming 500 MB for full history, - // and we are blocksLeft behind out of (target-1) total blocks (since block 0 is genesis) - double approximateSizeMB = 0.0; + // Estimate download size + QString sizeText; if (target > 1) { quint64 estimatedBytes = Utils::estimateSyncDataSize(blocksLeft); sizeText = Utils::formatBytes(estimatedBytes); } QString statusMsg = Utils::formatSyncStatus(height, target, daemonSync); - // Shows "# blocks remaining (approx. X MB)" to sync - // Shows "Wallet sync: # blocks remaining (approx. X MB)" - this->setStatusText(QString("%1 (approx. %2)").arg(statusMsg).arg(sizeText)); + // Show size estimate only if available + if (!sizeText.isEmpty()) { + this->setStatusText(QString("%1 (approx. %2)").arg(statusMsg).arg(sizeText)); + } else { + this->setStatusText(statusMsg); + } } m_statusLabelStatus->setToolTip(QString("Wallet Height: %1 | Network Tip: %2").arg(height).arg(target)); } diff --git a/src/WindowManager.cpp b/src/WindowManager.cpp index 38c4cd97..b0e50ec2 100644 --- a/src/WindowManager.cpp +++ b/src/WindowManager.cpp @@ -104,8 +104,12 @@ void WindowManager::close() { // Stop Tor manager threads torManager()->stop(); - // Wait for all threads in the global thread pool - QThreadPool::globalInstance()->waitForDone(); + // 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. " + << "Forcing exit to prevent use-after-free."; + std::_Exit(1); // Fast exit without cleanup - threads may still hold resources + } for (const auto &window: m_windows) { window->close(); diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 85ec7399..4c079f42 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -592,10 +592,9 @@ void Wallet::syncDateRange(const QDate &start, const QDate &end) { cryptonote::network_type nettype = m_wallet2->nettype(); QString filename = Utils::getRestoreHeightFilename(static_cast(nettype)); - auto lookup = RestoreHeightLookup::fromFile(filename, static_cast(nettype)); + std::unique_ptr lookup(RestoreHeightLookup::fromFile(filename, static_cast(nettype))); uint64_t startHeight = lookup->dateToHeight(start.startOfDay().toSecsSinceEpoch()); uint64_t endHeight = lookup->dateToHeight(end.startOfDay().toSecsSinceEpoch()); - delete lookup; if (startHeight >= endHeight) return; @@ -621,9 +620,11 @@ void Wallet::fullSync() { if (!storedHeight.isEmpty()) { originalHeight = storedHeight.toULongLong(); } else { - // Fallback (dangerous if skipped, but better than 0) + // Fallback: if skipToTip() was used, this may be the current tip, missing all transactions originalHeight = m_wallet2->get_refresh_from_block_height(); ->>>>>>> 43ee0e4e (Implement Skip Sync and Data Saving features) + qWarning() << "fullSync: No stored creation height found (feather.creation_height). " + << "Falling back to current refresh height:" << originalHeight + << ". This may miss transactions if skipToTip() was previously used."; } m_wallet2->set_refresh_from_block_height(originalHeight); @@ -672,6 +673,7 @@ bool Wallet::importTransaction(const QString &txid) { m_wallet2->scan_tx(txids); qInfo() << "Successfully imported transaction:" << txid; this->updateBalance(); + this->history()->refresh(); return true; } catch (const std::exception &e) { qWarning() << "Failed to import transaction: " << txid << ", error: " << e.what(); diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index 8dee4365..4b7d3d6b 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -532,8 +532,8 @@ private: QTimer *m_storeTimer = nullptr; std::set m_selectedInputs; - uint64_t m_stopHeight = 0; - bool m_rangeSyncActive = false; + std::atomic m_stopHeight{0}; + std::atomic m_rangeSyncActive{false}; }; #endif // FEATHER_WALLET_H diff --git a/src/utils/Utils.cpp b/src/utils/Utils.cpp index 55260154..a3339485 100644 --- a/src/utils/Utils.cpp +++ b/src/utils/Utils.cpp @@ -752,6 +752,7 @@ QString getPausedSyncStatus(Wallet *wallet, Nodes *nodes, QString *tooltip) { if (tooltip) { *tooltip = QString("Wallet Height: %1 | Network Tip: %2").arg(walletHeight).arg(daemonHeight); } + quint64 blocksBehind = (daemonHeight > startHeight) ? (daemonHeight - startHeight) : 0; if (blocksBehind == 0) { return "[PAUSED] Sync paused"; }