Skip to content

Conversation

@aisge
Copy link

@aisge aisge commented Sep 3, 2025

The TimeDisplayWidget retrieves the current song position using getMilliseconds() or playPos().
This time value is not reset to 0 when the Home key is pressed.

#7956

getPlayPos(playMode).setTicks( ticks );
getPlayPos(playMode).setCurrentFrame( 0.0f );
getPlayPos(playMode).setJumped( true );
setToTime(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this move the play pos to 0 no matter what ticks are passed to the function?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you are right — fixed it.

…ction would break).

Also fixed incorrect time information when navigating with left/right keys.
@bratpeki bratpeki self-assigned this Sep 4, 2025
@bratpeki
Copy link
Member

bratpeki commented Sep 4, 2025

Compiled because of the lack of workloads. LGTM.
@regulus79 can we get this reviewed and merged?

getPlayPos(playMode).setCurrentFrame( 0.0f );
getPlayPos(playMode).setJumped( true );
setToTime(0);
setToTimeByTicks(ticks);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why you need to call setToTime/setToTimeByTicks at all, since the play pos is already set a few lines above. Looking at the definitions of those functions, I suppose because setToTime also forcefully sets the millisecond counter (rather than incrementing it as done above on line 610), that may prevent some issues?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is that TimeDisplayWidget currently uses Song.getMilliseconds() in its updateTime() method.
getMilliseconds() is called without an explicit play mode (so the play mode is taken from the current song, which is set to NONE when stopped). But the position is set beforehand for the SONG play mode.

If I call setPlayPos() with the actual play mode instead of the fixed SONG mode, the indicator bar is not reset when pressing HOME.
So I guess this is the less invasive way to fix that bug.

Song::setPlayPos() is only invoked in the key event handler of SongEditor (left, right, home) and in clearProject(), so I assume it has no side effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants