From a7d31701abfab87792fc88ed0ae64237c6eb06b9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jan 2016 01:55:15 +0100 Subject: [PATCH] Work around a crash in wxD2DContext when using gcc Don't call GetSize() method as gcc can't handle aggregates returned by value from D2D libraries currently and the code just crashes if this method is called. See #17171. --- docs/changes.txt | 1 + src/msw/graphicsd2d.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 0658895d6c..fb0b4773d3 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -189,6 +189,7 @@ wxMSW: - Make wxListCtrl &c appearance more native on modern systems (Tobias Taschner). - Don't send wxActivateEvent for minimized windows (bzcdr). - Return correct OS version under Windows 8.1 and later. +- Fix crash in wxD2DContext when using non-MSVC compiler (iwbnwif). wxOSX/Cocoa: diff --git a/src/msw/graphicsd2d.cpp b/src/msw/graphicsd2d.cpp index b78a573b74..f61e540b93 100644 --- a/src/msw/graphicsd2d.cpp +++ b/src/msw/graphicsd2d.cpp @@ -3349,9 +3349,16 @@ void wxD2DContext::SetPen(const wxGraphicsPen& pen) void wxD2DContext::AdjustRenderTargetSize() { m_renderTargetHolder->Resize(); + + // Currently GetSize() can only be called when using MSVC because gcc + // doesn't handle returning aggregates by value as done by D2D libraries, + // see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64384. Not updating the + // size is not great, but it's better than crashing. +#ifdef __VISUALC__ D2D1_SIZE_F renderTargetSize = m_renderTargetHolder->GetD2DResource()->GetSize(); m_width = renderTargetSize.width; m_height = renderTargetSize.height; +#endif // __VISUALC__ } void wxD2DContext::ReleaseDeviceDependentResources()