Skip to content

fix(rgbww): own profile copy in singleton (meta #2580 A4) - #2588

Merged
zackees merged 1 commit into
masterfrom
fix/2580-rgbww-profile-copy
May 30, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/2580-rgbww-profile-copy

Conversation

@zackees

@zackees zackees commented May 30, 2026 •

Copy link
Copy Markdown
Member

Summary

set_rgbww_colorimetric_profile(const RgbcctProfile* profile) stored the caller's raw pointer in a singleton. Passing a stack-local RgbcctProfile (the natural usage from setup()) became a use-after-scope on the next get_rgbww_colorimetric_profile() call.

This PR changes the singleton storage to keep an owned copy of the profile (with a has_profile flag). nullptr still reverts to kRgbwwDefaultProfile. The public API signature is unchanged, so no callers break.

Addresses meta-issue #2580 finding A4 (originally CodeRabbit on #2560 — #2560 (comment)).

Test plan

  • bash lint
  • CI green

Summary by CodeRabbit

  • Refactor
    • Enhanced internal color profile state management to improve stability and memory safety.

Review Change Stack

set_rgbww_colorimetric_profile() previously stored the caller's raw
pointer in singleton state. Passing a stack-local RgbcctProfile turned
this into a use-after-scope on the next get_rgbww_colorimetric_profile()
call. Store an owned copy instead; nullptr still reverts to the default
profile. Public API signature is unchanged.

Addresses CodeRabbit finding A4 from meta #2580 (originally from #2560).
@zackees
zackees merged commit 63fade3 into master May 30, 2026
5 of 7 checks passed
@coderabbitai

coderabbitai Bot commented May 30, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: db9729cf-459b-4160-a441-b7c5137c4435

📥 Commits

Reviewing files that changed from the base of the PR and between 41c2dbb and ee3f53e.

📒 Files selected for processing (1)
  • src/fl/gfx/rgbww.cpp.hpp

📝 Walkthrough

Walkthrough

The PR eliminates a dangling pointer risk in the singleton colorimetric profile state. RgbwwColorimetricState now owns a RgbcctProfile copy with a has_profile flag instead of storing a caller-provided pointer. Profile getters and setters manage ownership and fallback to the global default explicitly.

Changes

Colorimetric Profile Ownership

Layer / File(s) Summary
Profile state memory safety
src/fl/gfx/rgbww.cpp.hpp
RgbwwColorimetricState stores an owned RgbcctProfile and has_profile flag instead of a raw pointer. Setter copies or clears; getter returns owned address or default based on flag.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit hops through color space,
No pointers left to chase,
With owned profiles held so tight,
The profiles stay safe in flight! 🎨✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/2580-rgbww-profile-copy

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 and usage tips.

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.

1 participant