Skip to content

setColorProfile() silently discards mGamma and mDitherMode: the warning checks two of the four fields it clears #4331

Closed

Description

@zackees

ChannelOptions::setColorProfile() clears four legacy settings:

mCorrection = UncorrectedColor;
mTemperature = UncorrectedTemperature;
mGamma.reset();
mDitherMode = DISABLE_DITHER;

Its one-time warning fires on two of them:

if (!had_profile &&
    (mCorrection != UncorrectedColor || mTemperature != UncorrectedTemperature) &&
    !mWarnedLegacyCleared) {
    FL_WARN_F("Color profile clears legacy correction/temperature");

So a caller who set options.mGamma = 2.2f, or options.mDitherMode = BINARY_DITHER, and left correction and temperature alone, has those silently discarded.

That is the failure mode the comment directly above the guard exists to prevent:

Warn only once validation has passed. Warning earlier consumed mWarnedLegacyCleared on a profile that was then rejected, and clearColorProfile() leaves mCorrection/mTemperature alone -- so the next valid profile cleared the caller's legacy settings silently.

The bug class is named in the comment; the condition just enumerates two of the four fields. The message is incomplete for the same reason — it says "correction/temperature" while clearing gamma and dither too.

Contract

#4034 C8.4 requires a one-time warning on transition, and #4156 R9 asked specifically for this:

Include existing ChannelOptions::mGamma in the managed-mode compatibility policy, alongside correction/temperature/dither, so a legacy default cannot add unintended shaping.

The policy exists. Two of the four fields are outside it.

The reverse direction has the same shape

setLegacyCorrection() and setLegacyTemperature() both call warnProfileCleared(); clearColorProfile();. There is no equivalent for gamma or dither because they are bare public fields — options.mGamma = 2.2f after a profile binds re-establishes legacy shaping with no warning and no profile clearing, where the same assignment to mCorrection via its setter would clear the profile.

That half is an API question (whether those fields grow setters) rather than a defect in an existing guard, so it is worth separating from the fix above.

Fix

Extend the condition to the fields actually cleared, and say so in the message. No behaviour change beyond a warning that should already have fired.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions