Skip to content

Fix binding loop on animationRunning in ScrollingText#270

Open
laurisvr wants to merge 1 commit into
ccatterina:mainfrom
laurisvr:fix/scrollingtext-binding-loop
Open

Fix binding loop on animationRunning in ScrollingText#270
laurisvr wants to merge 1 commit into
ccatterina:mainfrom
laurisvr:fix/scrollingtext-binding-loop

Conversation

@laurisvr

Copy link
Copy Markdown
Contributor

Hey, sorry it took me a bit but here's the PR for the animationRunning binding loop.

The problem was that animationRunning depends on label.x, and it was used in the text binding. Changing text changes implicitWidth, which changes animation.to, which changes label.x — completing the loop.

I split it into _animationActive (just !animation.paused && animation.running, no label.x) which is used in the text binding, and kept animationRunning with the label.x !== 0 check for the visibility and layer properties since those don't feed back into the animation.

Fixes #249

The text binding depended on animationRunning which includes
label.x, but changing text changes implicitWidth which feeds
back into animation.to and label.x, creating a loop.

Split into _animationActive (no label.x dependency) for the
text binding, while keeping animationRunning with label.x for
visibility and layer properties that don't feed back into the
animation chain.

Fixes ccatterina#249

Copilot AI 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.

Pull request overview

Resolves a QML binding loop in ScrollingText by decoupling the text binding from label.x-dependent animation state, addressing the “Binding loop detected … eventually crash” reports in #249.

Changes:

  • Introduces a new _animationActive flag (!animation.paused && animation.running) to use in the text binding.
  • Reworks animationRunning to compose label.x !== 0 with _animationActive, keeping prior semantics for visibility/layer usage.
  • Adds an inline comment documenting the original binding loop chain and rationale.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// animationRunning → text → implicitWidth → animation.to → label.x → animationRunning
property bool _animationActive: !animation.paused && animation.running
property bool animationRunning: label.x !== 0 || _animationActive
text: overflow ? (root.overflowElides && !_animationActive ? elidedMetrics.elidedText : root.textAndSpacing) : root.text

Copilot AI Feb 28, 2026

Copy link

Choose a reason for hiding this comment

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

Using _animationActive to choose between elidedMetrics.elidedText and root.textAndSpacing changes behavior when the animation becomes paused while label.x is non-zero (e.g., StopScrollOnMouseOver or when pausing mid-scroll): the text will immediately switch to the elided string, which changes label.implicitWidth, updates animation.to, and triggers reset() via onToChanged, effectively forcing label.x = 0 even when scrollResetOnPause is false. To preserve the previous “freeze at current offset when paused” behavior while still avoiding the binding loop, consider basing the decision on a state that doesn’t depend on label.x bindings (e.g., track a _hasScrolled flag imperatively in onXChanged/reset(), or use an animation time/state property that won’t feed back into implicitWidth).

Suggested change
text: overflow ? (root.overflowElides && !_animationActive ? elidedMetrics.elidedText : root.textAndSpacing) : root.text
text: overflow ? (root.overflowElides && !animation.running ? elidedMetrics.elidedText : root.textAndSpacing) : root.text

Copilot uses AI. Check for mistakes.
@ccatterina

Copy link
Copy Markdown
Owner

Hi @laurisvr , I tried the PR but unfortunately I still receive warnings for binding loops:

file:///home/claudio/.local/share/plasma/plasmoids/plasmusic-toolbar/contents/ui/components/ScrollingText.qml:87:9
file:///home/claudio/.local/share/plasma/plasmoids/plasmusic-toolbar/contents/ui/components/ScrollingText.qml:92:9: QML NumberAnimation: Binding loop detected for property "paused":
file:///home/claudio/.local/share/plasma/plasmoids/plasmusic-toolbar/contents/ui/components/ScrollingText.qml:95:13
file:///home/claudio/.local/share/plasma/plasmoids/plasmusic-toolbar/contents/ui/components/ScrollingText.qml:83:5: QML Label: Binding loop detected for property "_animationActive":

I'll see if I can find another solution.

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.

Got lot of Binding loop detected for property "XXXXXXX" and eventually crash my KDE panel after some times

3 participants