From 4d388e351ca088cb7db0e617218d34975a9263e0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 21 Sep 2017 18:04:24 +0200 Subject: [PATCH] Fix Direct2D graphics context after wxPenInfo changes At least in wxMSW wxPen::GetStipple() returns a non-null (but invalid) bitmap even when pen style is not wxPENSTYLE_STIPPLE, so don't test for this bitmap when creating a wxGraphicsPen from a wxPen but for the style directly. This avoids using this invalid bitmap later in D2D code, where it resulted in assert failures. Also add a similar style test before calling wxPen::GetDashes() for consistency, even if it doesn't seem to be strictly necessary. See https://github.com/wxWidgets/wxWidgets/pull/553 Closes #17958. --- src/common/graphcmn.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/common/graphcmn.cpp b/src/common/graphcmn.cpp index 7e91cdb306..817a4311e3 100644 --- a/src/common/graphcmn.cpp +++ b/src/common/graphcmn.cpp @@ -836,12 +836,18 @@ wxGraphicsPen wxGraphicsContext::CreatePen(const wxPen& pen) const .Cap(pen.GetCap()) ; - wxDash *dashes; - if ( int nb_dashes = pen.GetDashes(&dashes) ) - info.Dashes(nb_dashes, dashes); + if ( info.GetStyle() == wxPENSTYLE_USER_DASH ) + { + wxDash *dashes; + if ( int nb_dashes = pen.GetDashes(&dashes) ) + info.Dashes(nb_dashes, dashes); + } - if ( wxBitmap* const stipple = pen.GetStipple() ) - info.Stipple(*stipple); + if ( info.GetStyle() == wxPENSTYLE_STIPPLE ) + { + if ( wxBitmap* const stipple = pen.GetStipple() ) + info.Stipple(*stipple); + } return DoCreatePen(info); }