From 7ce588afab5cea2e731f799226e086d019638dff Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Tue, 20 Jul 2021 23:06:28 +0200 Subject: [PATCH] Don't use wxDC to get clipping box in wxGCDC We shouldn't call wxDCImpl::DoGetClippingRect() from wxGCDCImpl::DoGetClippingRect() because it wouldn't return the correct result if there is an affine transformation applied to this DC, as wxDCImpl is not aware of such transformations. --- src/common/dcgraph.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 45c151426b..4427c260a1 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -355,7 +355,18 @@ bool wxGCDCImpl::DoGetClippingRect(wxRect& rect) const self->UpdateClipBox(); } - return wxDCImpl::DoGetClippingRect(rect); + // We shouldn't call wxDCImpl::DoGetClippingRect() here + // because it wouldn't return the correct result if there is + // affine transformation applied to this DC, as the base + // class is not aware of affine transformations. + // We can just use the value returned by our UpdateClipBox() + // which is already correct. + if ( m_clipX1 == m_clipX2 || m_clipY1 == m_clipY2 ) + rect = wxRect(); // empty clip region + else + rect = wxRect(m_clipX1, m_clipY1, m_clipX2 - m_clipX1, m_clipY2 - m_clipY1); + + return m_clipping; } void wxGCDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h )