From 31a1584724f0d7c3f85b1bf6f340480febefdf52 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 28 Dec 2012 16:03:12 +0000 Subject: [PATCH] Don't call wxTextMeasure::BeginMeasuring() when using non-native wxDC. This is useless as we don't use wxTextMeasure in this case but just forward to the wxDC itself, and also results in an assert in wxMSW wxTextMeasure implementation. Closes #14916. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73292 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/private/textmeasure.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/wx/private/textmeasure.h b/include/wx/private/textmeasure.h index 4788c992ed..393946e7bf 100644 --- a/include/wx/private/textmeasure.h +++ b/include/wx/private/textmeasure.h @@ -75,6 +75,9 @@ public: virtual void BeginMeasuring() { } virtual void EndMeasuring() { } + // This is another method which is only used by MeasuringGuard. + bool IsUsingDCImpl() const { return m_useDCImpl; } + protected: // RAII wrapper for the two methods above. class MeasuringGuard @@ -82,12 +85,16 @@ protected: public: MeasuringGuard(wxTextMeasureBase& tm) : m_tm(tm) { - m_tm.BeginMeasuring(); + // BeginMeasuring() should only be called if we have a native DC, + // so don't call it if we delegate to a DC of unknown type. + if ( !m_tm.IsUsingDCImpl() ) + m_tm.BeginMeasuring(); } ~MeasuringGuard() { - m_tm.EndMeasuring(); + if ( !m_tm.IsUsingDCImpl() ) + m_tm.EndMeasuring(); } private: -- 2.45.2