From cb05935f529cb270f5c0856b2649e4b0c7db830f Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Wed, 20 Apr 2022 01:03:15 +0200 Subject: [PATCH] Check if GetDPI parameters are not NULL And combine the same code for assigning the variables. --- src/common/graphcmn.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/common/graphcmn.cpp b/src/common/graphcmn.cpp index 179e0f2fc6..1143fe4a7b 100644 --- a/src/common/graphcmn.cpp +++ b/src/common/graphcmn.cpp @@ -627,19 +627,12 @@ wxDouble wxGraphicsContext::GetAlpha() const void wxGraphicsContext::GetDPI( wxDouble* dpiX, wxDouble* dpiY) const { - if ( m_window ) - { - const wxSize ppi = m_window->GetDPI(); - *dpiX = ppi.x; - *dpiY = ppi.y; - } - else - { - // Use some standard DPI value, it doesn't make much sense for the - // contexts not using any pixels anyhow. - *dpiX = wxDisplay::GetStdPPIValue(); - *dpiY = wxDisplay::GetStdPPIValue(); - } + const wxSize dpi = GetWindow() ? GetWindow()->GetDPI() : wxDisplay::GetStdPPI(); + + if (dpiX) + *dpiX = dpi.x; + if (dpiY) + *dpiY = dpi.y; } wxSize wxGraphicsContext::FromDIP(const wxSize& sz) const