Fix check for existing clipping region in wxDCClipper

wxDC::GetClippingBox() is actually supposed to return a rectangle equal
to the total wxDC area and not an empty rectangle if there is no
clipping box at all, so avoid restoring the old clipping region
unnecessarily in this case too: even if it should be harmless, it's
still unnecessarily inefficient and, in practice, this is not really
harmless neither as wxPdfDC (from the third party wxPdfDocument library)
doesn't handle having a clipping region set when adding a new page
correctly and so using wxDCClipper broke PDF generation.

This fixes another fallout from 2a8c290e0d

See #13834.
This commit is contained in:
Vadim Zeitlin
2018-06-18 10:21:59 +02:00
parent fe0f9fefe4
commit 119dce5eb8

View File

@@ -1459,7 +1459,14 @@ private:
// Common part of all ctors.
void Init(const wxRect& r)
{
// GetClippingBox() is supposed to return the rectangle corresponding
// to the full DC area and some implementations actually do it, while
// others return an empty rectangle instead. Check for both possible
// results here to avoid restoring the clipping region unnecessarily in
// the dtor.
m_dc.GetClippingBox(m_oldClipRect);
if ( m_oldClipRect == m_dc.GetSize() )
m_oldClipRect = wxRect();
m_dc.SetClippingRegion(r);
}