From 74306708bc5e4f9bd04916d1e2cb60084ffa8177 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 28 Jul 2018 11:43:31 +0200 Subject: [PATCH] Fix retrieving empty bounding box for D2D graphics path Return "zero rectangle" (0, 0, 0, 0) if bounding box is empty. --- src/msw/graphicsd2d.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/msw/graphicsd2d.cpp b/src/msw/graphicsd2d.cpp index da36e77523..fe3b2a4dd5 100644 --- a/src/msw/graphicsd2d.cpp +++ b/src/msw/graphicsd2d.cpp @@ -1847,11 +1847,17 @@ void wxD2DPathData::GetBox(wxDouble* x, wxDouble* y, wxDouble* w, wxDouble *h) c { D2D1_RECT_F bounds; ID2D1Geometry *curGeometry = GetFullGeometry(); - curGeometry->GetBounds(D2D1::Matrix3x2F::Identity(), &bounds); - if (x != NULL) *x = bounds.left; - if (y != NULL) *y = bounds.top; - if (w != NULL) *w = bounds.right - bounds.left; - if (h != NULL) *h = bounds.bottom - bounds.top; + HRESULT hr = curGeometry->GetBounds(D2D1::Matrix3x2F::Identity(), &bounds); + wxCHECK_HRESULT_RET(hr); + // Check if bounds are empty + if ( bounds.left > bounds.right ) + { + bounds.left = bounds.top = bounds.right = bounds.bottom = 0.0F; + } + if (x) *x = bounds.left; + if (y) *y = bounds.top; + if (w) *w = bounds.right - bounds.left; + if (h) *h = bounds.bottom - bounds.top; } bool wxD2DPathData::Contains(wxDouble x, wxDouble y, wxPolygonFillMode WXUNUSED(fillStyle)) const