Suspicious behavior in Component::paintComponentAndChildren()

This might be kind of a corner case, but at the beginning of said method there is:

if (flags.dontClipGraphicsFlag)
    paint (g);
    /* yfede: there is no save/restore of the Graphics' state, so opacity, colour, 
     and origin coordinates that might have been changed inside paint() will 
     remain, affecting the painting of children that comes afterward */
    Graphics::ScopedSaveState ss (g);

    if (! (ComponentHelpers::clipObscuredRegions (*this, g, clipBounds, {}) && g.isClipEmpty()))
        paint (g);

// and then comes the painting of the children

When the dontClipGraphicsFlag is true, it looks like a Graphics::setOpacity(); called inside the paint() might “bleed”, reaching and thus affecting also the painting of the children that comes afterward, because the Graphics state is not saved and restored in that case.


not also that if you call setPaintingIsUnclipped (true) on a component then it will always get repainted whenever its child is repainted, even if it’s unnecessary (that’s an issue previously reported here), so perhaps the test should be changed to

if (flags.dontClipGraphicsFlag && getNumChildComponents() == 0)