Check if GetDPI parameters are not NULL

And combine the same code for assigning the variables.
This commit is contained in:
Maarten Bent
2022-04-20 01:03:15 +02:00
parent ef28ac392c
commit cb05935f52

View File

@@ -627,19 +627,12 @@ wxDouble wxGraphicsContext::GetAlpha() const
void wxGraphicsContext::GetDPI( wxDouble* dpiX, wxDouble* dpiY) const void wxGraphicsContext::GetDPI( wxDouble* dpiX, wxDouble* dpiY) const
{ {
if ( m_window ) const wxSize dpi = GetWindow() ? GetWindow()->GetDPI() : wxDisplay::GetStdPPI();
{
const wxSize ppi = m_window->GetDPI(); if (dpiX)
*dpiX = ppi.x; *dpiX = dpi.x;
*dpiY = ppi.y; if (dpiY)
} *dpiY = dpi.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();
}
} }
wxSize wxGraphicsContext::FromDIP(const wxSize& sz) const wxSize wxGraphicsContext::FromDIP(const wxSize& sz) const