first color/style change not rendered until a second change occurs#77
Merged
Conversation
Collaborator
Author
Review: the fix is correct, minimal, and low-risk ✅I traced the full token lifecycle in Root cause — confirmed accurate
Removing the No regression risk
Test coverage — solid, one small gap
|
Zeljko-Predjeskovic
force-pushed
the
fix/pin_didnt_color
branch
from
July 17, 2026 11:54
11ff2ce to
f62c4c3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: first color/style change not rendered until a second change occurs
Problem
Recoloring an element (e.g. a pin) with the color tool was inconsistent — the first color change often had no visible effect, and only a second change (or an intervening pan/zoom) made it show. The element model updated immediately; only the rendered output lagged.
Cause
Each SvgVisualElement caches its fill/stroke brush per renderer and rebuilds it only when its attribute-change token changes. The token starts as Guid.Empty and begins tracking only after the first render, so an element enters its first render still holding Empty. SetAttributeChangeToken treated Empty as "initial, don't dispose," which swallowed the first real change — the stale old-color brush kept being drawn until a second change flipped the token again.
Fix
Always rebuild the cached pens/brushes when the token differs. Disposing a freshly-created entry is a no-op (its brushes are null), so the Guid.Empty special-case is unnecessary and was the bug.
Single-line change in Svg/Basic Shapes/SvgVisualElement.cs. Applies to all visual elements, not just pins.