Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix note rendering when labels are present. #4557

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Dec 12, 2023

Identify the Bug or Feature request

Improves #3691

Description of the Change

With the switch to setRenderingHints() for restoring graphics state, we ran into a bug in Graphics2D where its cached font state is not invalidated since it doesn't detect that a change has occurred. This causes the wrong state to be used back in paintComponent(), but only if the problematic state is in play (e.g., if a label has been rendered).

The new approach has renderZone() work on a copy of the Graphics2D object, so that paintComponent() isn't affected by any changes to its state. This also removes the need for renderZone() to reset any state, including rendering hints and clips. To be sure it works properly, paintComponent() has to set its font prior to rendering the notes now.

Possible Drawbacks

Should be none.

Documentation Notes

N/A

Release Notes

N/A


This change is Reviewable

`renderZone()` now uses a copy of the graphics object so that `paintComponent()` isn't affected by any changes. This
also means no need to restore graphics state (rendering hints, clip, etc) at the end of `renderZone()`.

Beyond being more reliable, this avoids a bug in `Graphics2D`, where `setRenderingHints()` does not properly detect font
state changes, unlike `setRenderingHint()`. We used to use `setRenderingHint()` but hit this bug since moving to
`setRenderingHints()`.
Copy link
Collaborator

@bubblobill bubblobill left a comment

Choose a reason for hiding this comment

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

Strange bug.
The fix seems sound to me.

@cwisniew cwisniew added the bug label Dec 15, 2023
@cwisniew cwisniew added this pull request to the merge queue Dec 15, 2023
Merged via the queue into RPTools:develop with commit cf94671 Dec 15, 2023
4 checks passed
@kwvanderlinde kwvanderlinde deleted the bugfix/3691-note-rendering branch December 15, 2023 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

3 participants