From 320acc1796c935e0eaf29da68f437eb7bf72a3cb Mon Sep 17 00:00:00 2001 From: Robin Dunn <> Date: Wed, 7 Aug 2019 15:38:28 -0700 Subject: [PATCH] Only clone the gradient's matrix when there is one --- src/osx/carbon/graphics.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index 2614051455..5e2c89e3d7 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -475,6 +475,7 @@ void * wxMacCoreGraphicsMatrixData::GetNativeMatrix() const } + // ---------------------------------------------------------------------------- // Pen and Brush common data. Base class for information shared between pens and // brushes, basically just the things needed for gradient support. @@ -587,8 +588,11 @@ wxMacCoreGraphicsPenBrushDataBase::CreateLinearGradientShading( CGPointMake((CGFloat) x2, (CGFloat) y2), m_gradientFunction, true, true ); m_isShading = true; - m_shadingMatrix = (wxMacCoreGraphicsMatrixData*)((wxMacCoreGraphicsMatrixData*)matrix.GetRefData())->Clone(); - m_shadingMatrix->Invert(); + if (! matrix.IsNull() ) + { + m_shadingMatrix = (wxMacCoreGraphicsMatrixData*)((wxMacCoreGraphicsMatrixData*)matrix.GetRefData())->Clone(); + m_shadingMatrix->Invert(); + } } void @@ -605,8 +609,11 @@ wxMacCoreGraphicsPenBrushDataBase::CreateRadialGradientShading( CGPointMake((CGFloat) xc, (CGFloat) yc), (CGFloat) radius, m_gradientFunction, true, true ); m_isShading = true; - m_shadingMatrix = (wxMacCoreGraphicsMatrixData*)((wxMacCoreGraphicsMatrixData*)matrix.GetRefData())->Clone(); - m_shadingMatrix->Invert(); + if (! matrix.IsNull() ) + { + m_shadingMatrix = (wxMacCoreGraphicsMatrixData*)((wxMacCoreGraphicsMatrixData*)matrix.GetRefData())->Clone(); + m_shadingMatrix->Invert(); + } } void wxMacCoreGraphicsPenBrushDataBase::CalculateShadingValues(void *info, const CGFloat *in, CGFloat *out)