Skip to content

Commit 80fa525

Browse files
UdjinM6PastaPastaPasta
authored andcommitted
qt: simplify splash fallback progress state
Reset curProgress whenever the splash changes phases so stale numeric progress from the previous phase cannot leak into the next one before a fresh ShowProgress update arrives. Also drop the separate phaseIsLong state and use a single fallback curve for phases that only emit initMessage(). After wiring startup rescans to real wallet ShowProgress updates, the extra slow-fallback state no longer buys us anything.
1 parent b0013af commit 80fa525

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

src/qt/splashscreen.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,14 @@ bool SplashScreen::eventFilter(QObject * obj, QEvent * ev) {
265265
qreal SplashScreen::calcOverallProgress() const
266266
{
267267
if (curProgress >= 0) {
268-
// Phase with real sub-progress: interpolate linearly within phase range
268+
// When a phase reports real sub-progress, map that 0-100 value into the
269+
// phase's assigned range directly.
269270
return phaseStart + (phaseEnd - phaseStart) * (curProgress / 100.0);
270271
}
271-
// Phase without sub-progress: exponential approach toward phaseEnd
272+
// Otherwise fall back to a time-based curve so phases driven only by
273+
// initMessage() still show movement without claiming exact progress.
272274
qreal elapsed = phaseTimer.elapsed() / 1000.0;
273-
// Long phases (rescan, wallet load) can take minutes/hours — use a very slow curve
274-
// Normal phases: reaches ~90% of range in ~15s
275-
// Long phases: reaches ~50% in ~2min, ~75% in ~5min
276-
qreal tau = phaseIsLong ? 120.0 : 5.0;
277-
qreal fraction = 1.0 - std::exp(-elapsed / tau);
275+
qreal fraction = 1.0 - std::exp(-elapsed / 5.0);
278276
return phaseStart + (phaseEnd - phaseStart) * fraction * EXPONENTIAL_FILL_CAP;
279277
}
280278

@@ -365,6 +363,9 @@ void SplashScreen::showMessage(const QString &message, int alignment, const QCol
365363
if (phase_changed) {
366364
m_current_phase = phase;
367365
m_current_phase_message = message;
366+
// Progress values are phase-local; drop any numeric progress from the
367+
// previous phase until a new ShowProgress update arrives.
368+
curProgress = -1;
368369
if (phase->snapsToEnd) {
369370
// Final phase: snap to 100% immediately since the splash
370371
// will be destroyed moments after "Done loading" arrives
@@ -377,11 +378,9 @@ void SplashScreen::showMessage(const QString &message, int alignment, const QCol
377378
displayProgress = 0.0;
378379
phaseStart = phase->start;
379380
phaseEnd = phase->end;
380-
phaseIsLong = true;
381381
animTimer.start(30);
382382
} else {
383383
// Normal phase: ensure we never jump backwards
384-
phaseIsLong = false;
385384
phaseStart = std::max(phase->start, displayProgress);
386385
phaseEnd = std::max(phase->end, phaseStart);
387386
}

src/qt/splashscreen.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public Q_SLOTS:
7373
// Phase-based progress tracking
7474
qreal phaseStart{0.0}; // Overall progress at start of current phase
7575
qreal phaseEnd{0.0}; // Overall progress at end of current phase
76-
bool phaseIsLong{false}; // True for long independent phases (rescan, wallet load)
7776
QElapsedTimer phaseTimer; // Time since current phase started
7877
const struct PhaseInfo* m_current_phase{nullptr}; // Current phase (defined in splashscreen.cpp)
7978
QString m_current_phase_message; // Message that triggered current phase

0 commit comments

Comments
 (0)