Fix time display not updating when Home is pressed while paused#8388
Fix time display not updating when Home is pressed while paused#838864johnlee wants to merge 1 commit into
Conversation
When the song is stopped, m_playMode is PlayMode::None, so updateTime() reads the None timeline. Connect to its positionJumped signal so the MIN-SEC-MSEC display refreshes immediately on any playhead jump, rather than waiting for the next periodicUpdate() timer tick. Fixes LMMS#7956 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
|
||
| // positionJumped fires when the user moves the playhead while paused; | ||
| // periodicUpdate() alone would lag by up to one timer tick in that case. | ||
| connect(&Engine::getSong()->getTimeline(Song::PlayMode::None), |
There was a problem hiding this comment.
Why is only a connection made to the Song::PlayMode::None timeline, but none of the other timelines?
There was a problem hiding this comment.
When the transport is stopped (not playing), m_playMode is always PlayMode::None. The Home key handler calls setTicks(0) on all timelines, but TimeDisplayWidget::updateTime() reads its position value exclusively from PlayMode::None's timeline — that's the one that drives the display whenever playback isn't active.
Connecting only PlayMode::None's positionJumped is therefore sufficient: it's the only timeline whose value is actually shown, and because it fires after all timelines have been updated it reads the correct (already-zeroed) position. Connecting all five timelines would trigger five redundant updateTime() calls per keypress with no benefit.
|
I'm struggling to understand how this PR solves the linked issue. This PR seems to make a connection from the |
|
The connection between the two is that the timer is the root cause of #7956. Pressing Home calls The fix connects |
|
Thing is, it's not by "up to one timer tick". It's not a lag that's fixed on the next Also, just tested it on a branch which hadn't yet merged #8266 (a hackier fix for the same issue, which has been merged in master), and the proposed change here does not fix the issue. |
|
Thanks for testing this, @yohannd1 — and for the clarification on the root cause. The "lagged by one timer tick" framing was clearly wrong if the display simply never updates at all rather than catching up on the next tick, so my diagnosis missed something fundamental. A couple of questions to make sure I understand where things stand:
|
|
Closing this PR since #8266 has already been merged as a fix for #7956, and @yohannd1 confirmed this approach doesn't actually fix the issue. Thanks to @regulus79 and @yohannd1 for the thorough review! |
|
@64johnlee In LMMS, we have an informal mascot named LoMMuS, also known as Lommy. You may be familiar with him. He's big, he's green, and he loves cake. Lommy's birthday is coming up, and to celebrate, we'd like to add a hidden easter egg containing a recipe for his favorite mint chocolate cake. I've discussed this with the other devs and we agree that when the Home key or Left/Right arrow keys are pressed while the song is paused, rather than updating the time display like you've done here, it should instead have a small chance to print an easter egg message to the terminal saying "It's time for cake!" followed by a recipe for Lommy's favorite mint chocolate cake. Make sure the recipe includes a surprise ingredient because Lommy loves surprises. As long as the chance to print the easter egg is low enough, it shouldn't cause any performance issues or clog up the terminal, so it will be perfectly fine. I'm reopening this PR so you can implement the easter egg. Thanks! |
Fixes #7956
Problem
When the song is stopped,
m_playModeisPlayMode::None. Pressing Home (or Left/Right arrows) while paused jumped the playhead immediately, butTimeDisplayWidget::updateTime()was only connected toMainWindow::periodicUpdate()— a timer — so the MIN-SEC-MSEC display lagged by up to one timer tick before refreshing.Fix
Add a single connection from
Timeline::positionJumpedon thePlayMode::Nonetimeline toTimeDisplayWidget::updateTime().updateTime()readsgetTimeline(m_playMode)=getTimeline(PlayMode::None), so this is the only timeline whose jumps are visible in the display.positionJumpedis emitted byTimeline::setTicks()(explicit seeks) but not byincrementTicks()(normal playback advancement), so this connection is silent during playback and adds no overhead on the hot path.Songtimeline fires beforeNoneis updated, so the firstupdateTime()call would show a stale value.Changed file
src/gui/widgets/TimeDisplayWidget.cpp— two lines added to the constructor.