From 0476cf379151d7e1eebf952f268db15f3618e77b Mon Sep 17 00:00:00 2001 From: Mariano Reingart Date: Mon, 19 Jan 2015 03:01:18 +0000 Subject: [PATCH] Fix problem with clipping region in wxqt. QPainter cannot set the clipping region when it is not active. Thanks @seandepagnier git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78385 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/qt/dc.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/qt/dc.cpp b/src/qt/dc.cpp index 807eff068b..09edfa1ffe 100644 --- a/src/qt/dc.cpp +++ b/src/qt/dc.cpp @@ -64,6 +64,20 @@ void wxQtDCImpl::QtPreparePainter( ) m_qtPainter->setPen( wxPen().GetHandle() ); m_qtPainter->setBrush( wxBrush().GetHandle() ); m_qtPainter->setFont( wxFont().GetHandle() ); + + if (m_clipping) + { + wxRegionIterator ri(*m_clippingRegion); + bool append = false; + while (ri.HaveRects()) + { + wxRect r = ri.GetRect(); + m_qtPainter->setClipRect( r.x, r.y, r.width, r.height, + append ? Qt::IntersectClip : Qt::ReplaceClip ); + append = true; + ri++; + } + } } else { @@ -347,9 +361,12 @@ void wxQtDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, } else { - // Set QPainter clipping (intersection if not the first one) - m_qtPainter->setClipRect( x, y, width, height, - m_clipping ? Qt::IntersectClip : Qt::ReplaceClip ); + if (m_qtPainter->isActive()) + { + // Set QPainter clipping (intersection if not the first one) + m_qtPainter->setClipRect( x, y, width, height, + m_clipping ? Qt::IntersectClip : Qt::ReplaceClip ); + } // Set internal state for getters /* Note: Qt states that QPainter::clipRegion() may be slow, so we @@ -414,7 +431,9 @@ void wxQtDCImpl::DestroyClippingRegion() { ResetClipping(); m_clippingRegion->Clear(); - m_qtPainter->setClipping( false ); + + if (m_qtPainter->isActive()) + m_qtPainter->setClipping( false ); } bool wxQtDCImpl::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,