Skip to content

DIVIDE_BY_ZERO & timecode out-of-sync fix - #11937

Merged
grliszas14 merged 4 commits into
audacity:masterfrom
grliszas14:ruler_formatter_fix
Sep 14, 2026
Merged

grliszas14 merged 4 commits into
audacity:masterfrom
grliszas14:ruler_formatter_fix

Conversation

@grliszas14

Copy link
Copy Markdown
Contributor

Resolves: #11925
Resolves: #11397
Resolves: EXCEPTION_INT_DIVIDE_BY_ZERO mentioned on Sentry

  • I signed CLA
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

QA:

  • Testflow test cases have been run

@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: cf97907c-1516-495d-87a3-650cd9ecb497

📥 Commits

Reviewing files that changed from the base of the PR and between e49114a23ab5c539b29eae4f377dc66434c81528 and ce637c354b65311f544dea496e065c20f3355cb9.

📒 Files selected for processing (4)
  • src/playback/view/toolbars/playbacktoolbartimeitem.cpp
  • src/playback/view/toolbars/playbacktoolbartimeitem.h
  • src/projectscene/view/statusbar/selectionstatusmodel.cpp
  • src/projectscene/view/statusbar/selectionstatusmodel.h

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change synchronizes toolbar and selection-model time signature notifications with project updates. Numeric timing components now use valid defaults and tolerate zero or negative values during beat formatting. Regression tests cover zero and negative time signatures. Playhead dragging and release now clamp positions to the timeline start.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TrackeditProject
  participant PlaybackToolBarTimeItem
  participant SelectionStatusModel
  PlaybackToolBarTimeItem->>TrackeditProject: Subscribe to timeSignatureChanged()
  SelectionStatusModel->>TrackeditProject: Subscribe to timeSignatureChanged()
  TrackeditProject->>PlaybackToolBarTimeItem: Emit timeSignatureChanged()
  PlaybackToolBarTimeItem-->>PlaybackToolBarTimeItem: Re-emit timeSignatureChanged()
  TrackeditProject->>SelectionStatusModel: Emit timeSignatureChanged()
  SelectionStatusModel-->>SelectionStatusModel: Re-emit timeSignatureChanged()
Loading

Merge Risk: ⚪ Minimal · up to e5ef5

This change hardens bar-beat formatting and keeps the playhead from seeking before the timeline start. The supplied evidence indicates the intended safeguards and regression coverage are present, with no concrete unresolved current-head risk.

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes the linked issues and checklist responses, but it does not include the required short description of the changes and their motivation. Add a short description that explains the divide-by-zero fix, bar-beat timecode synchronization fix, playhead clamping, and the motivation for these changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main changes: divide-by-zero handling and timecode synchronization fixes.
Linked Issues check ✅ Passed The changes address both linked issues. The timecode and project-change updates target bar-beat synchronization for non-120 BPM values [#11925]. The timeline clamping prevents dragging the playhead be…
Out of Scope Changes check ✅ Passed The formatter safeguards, default values, project-change handling, synchronization updates, tests, and playhead clamping are related to the stated divide-by-zero, timecode, and playhead objectives.

Warning

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped musescore/musescore.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: 013eea8c-bfc0-4661-bbda-0a153025e1dc

📥 Commits

Reviewing files that changed from the base of the PR and between ed63687 and 88355847f67b3100b7fee488461b525fd5399285.

📒 Files selected for processing (9)
  • src/playback/view/toolbars/playbacktoolbartimeitem.cpp
  • src/playback/view/toolbars/playbacktoolbartimeitem.h
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TracksItemsView.qml
  • src/projectscene/view/statusbar/selectionstatusmodel.cpp
  • src/projectscene/view/statusbar/selectionstatusmodel.h
  • src/uicomponents/components/internal/numeric/beatsformatter.cpp
  • src/uicomponents/components/internal/numeric/numericviewmodel.h
  • src/uicomponents/components/internal/numeric/timecodeformatter.h
  • src/uicomponents/tests/timecodemodel_tests.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

configuration()->playbackTimeItemFormatChanged().onNotify(this, [this](){
emit currentFormatChanged();
});
}

void PlaybackToolBarTimeItem::listenTimeSignatureChanges()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this listen something standard?

is it to translate something like "detecting" "reacting" to a change?

what about timeSignatureChangesCallback maybe better in singular timeSignatureChangeCallback

btw shouldn't we use a lambda for that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yep, we already have such listeners across the codebase so I'd like it as is

Comment on lines +55 to +68
void SelectionStatusModel::listenTimeSignatureChanges()
{
emit timeSignatureChanged();

auto project = globalContext()->currentTrackeditProject();
if (!project) {
return;
}

project->timeSignatureChanged().onReceive(this, [this](const trackedit::TimeSignature&) {
emit timeSignatureChanged();
});
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we relay the change ?

shouldn't we review who's interested in the change callback in first place?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, timeSignatureChanged is literally the NOTIFY signal of the tempo/upperTimeSignature/lowerTimeSignature Q_PROPERTYs

Comment on lines 58 to +63
{
if (m_tempo <= 0 || m_upperTimeSignature <= 0 || m_lowerTimeSignature <= 0) {
updateFields(MIN_DIGITS[0]);
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldn't we expect at least 1 or more ?

should we also do the top cap ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

previously variables were initialized to 0 and as sentry report shows there's a case when we access those before those variables are filled with proper values (happens only on Windows x86)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

about the top cap: TimeSignature popup clamps upper to 1-128 and lower to {2,4,8,16,32,64} so I think top cap is not needed, we're checking only the validity there

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

from what I see those were init at -1 hence that fix is valid but at the same time now we init with more "normal" values 120 bpm 4/4 so isthis check really still relevant?

@grliszas14
grliszas14 merged commit 97d74f4 into audacity:master Sep 14, 2026
4 of 10 checks passed
@grliszas14
grliszas14 deleted the ruler_formatter_fix branch September 14, 2026 12:55
kryksyh added a commit that referenced this pull request Sep 22, 2026
DIVIDE_BY_ZERO & timecode out-of-sync fix (#11937)
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.

Playhead loses accuracy to Bar-Beat gradually when setting past 120 BPM. Playhead can be dragged before 0 mark

2 participants