Nested ClippingRectangleNode bug. Adding a nested clip rect prevent the parent's clip rect from working

I’ve had a problem for a good while now with nested clipping rectangles. I’ve managed to reduce the bug down to this small code snippet:

cocos2d::ClippingRectangleNode *wndClip = cocos2d::ClippingRectangleNode::create();
cocos2d::ClippingRectangleNode *listClip = cocos2d::ClippingRectangleNode::create();
wndClip->setClippingRegion(cocos2d::Rect(20, 20, 400, 400));
listClip->setClippingRegion(cocos2d::Rect(20, 20, 200, 200));

cocos2d::DrawNode *wndItem = cocos2d::DrawNode::create();
cocos2d::DrawNode *listItem = cocos2d::DrawNode::create();
wndItem->drawSolidCircle(cocos2d::Vec2(0, 0), 1000, 0, 100, cocos2d::Color4F(0, 1, 0, 0.5f));
listItem->drawSolidCircle(cocos2d::Vec2(0, 0), 1000, 0, 100, cocos2d::Color4F(1, 0, 0, 0.5f));

addChild(wndClip);
wndClip->addChild(listClip);
wndClip->addChild(wndItem);
listClip->addChild(listItem);

The green circle represents window’s contents, the red circle represents a list item. Both circles should be clipped, but when listClip is added, wndClip no longer clips the red circle. Commenting out the line wndClip->addChild(listClip); will make wndClip work as expected.

Is there a workaround or temporary fix for this bug? Thanks.

As usual I solved my own problem upon posting it.

I added glPushAttrib(GL_SCISSOR_BIT) to the start of ClippingRectangleNode::onBeforeVisitScissor() and glPopAttrib() at the end of ClippingRectangleNode::onAfterVisitScissor().