From 72790218cb10e402a5774e87889cb6763c087c73 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 29 Jan 2018 15:36:21 +0100 Subject: [PATCH] Fix wrongly restoring clipping region in wxDCClipper The change of 2a8c290e0de5e657f22a0c13817df65688b01345 was wrong as it unconditionally restored m_oldClipRect in dtor, even when it was empty, indicating that no clipping had been in effect when wxDCClipper was constructed. This totally broke all the code using wxDCClipper, notably generic wxListCtrl which wasn't repainted correctly at all. Fix this by checking if the clipping rectangle is not empty before restoring it, this should work as well as we can make it without having GetClippingRegion() that could return an invalid region if no clipping is in effect. See #13834. Closes #18066. --- include/wx/dc.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/wx/dc.h b/include/wx/dc.h index dadbe793a3..38edf9da5f 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -1454,7 +1454,8 @@ public: ~wxDCClipper() { m_dc.DestroyClippingRegion(); - m_dc.SetClippingRegion(m_oldClipRect); + if ( !m_oldClipRect.IsEmpty() ) + m_dc.SetClippingRegion(m_oldClipRect); } private: