Component::clipObscuredRegions probably bug

Recently i got paint() calls with empty clip-regions, i think i found the reason. Whenever something will be removed from the current clip region it sets nothingChanged to false.

But clipObscuredRegions() calls also itself to remove regions from its probably opaque children.

Than clipObscuredRegions returns false, which causes nothingChanged still to stay true, adding a "!" before clipObscuredRegions solves the problem.


 

    static bool clipObscuredRegions (const Component& comp, Graphics& g, const Rectangle clipRect, Point delta)
    {
        bool nothingChanged = true;

        for (int i = comp.childComponentList.size(); --i >= 0;)
        {
            const Component& child = *comp.childComponentList.getUnchecked(i);

            if (child.isVisible() && ! child.isTransformed())
            {
                const Rectangle newClip (clipRect.getIntersection (child.bounds));

                if (! newClip.isEmpty())
                {
                    if (child.isOpaque() && child.componentTransparency == 0)
                    {
                        g.excludeClipRegion (newClip + delta);
                        nothingChanged = false;
                    }
                    else
                    {
                        const Point childPos (child.getPosition());
                        //  
                        if (!clipObscuredRegions (child, g, newClip - childPos, childPos + delta))
                            nothingChanged = false;  // insert "!" before clipObscuredReqions
                    }
                }
            }
        }

        return nothingChanged;
    }

The logic there is making my head hurt! But thanks, I'll investigate..

I thing the "negative true" (nothing changed) is what makes it complicated to read 

Yeah, I rewrote it more clearly.