Prevent crash when attempting to clear a DC with not device under wxQT

This commit is contained in:
Graham Dawes
2018-12-20 13:41:02 +00:00
parent 172a97e411
commit 5c3ddb7a7f

View File

@@ -115,14 +115,46 @@ bool wxQtDCImpl::CanGetTextExtent() const
void wxQtDCImpl::DoGetSize(int *width, int *height) const void wxQtDCImpl::DoGetSize(int *width, int *height) const
{ {
if (width) *width = m_qtPainter->device()->width(); QPaintDevice *pDevice = m_qtPainter->device();
if (height) *height = m_qtPainter->device()->height();
int deviceWidth;
int deviceHeight;
if (pDevice)
{
deviceWidth = pDevice->width();
deviceHeight = pDevice->height();
}
else
{
deviceWidth = 0;
deviceHeight = 0;
}
if (width) *width = deviceWidth;
if (height) *height = deviceHeight;
} }
void wxQtDCImpl::DoGetSizeMM(int* width, int* height) const void wxQtDCImpl::DoGetSizeMM(int* width, int* height) const
{ {
if (width) *width = m_qtPainter->device()->widthMM(); QPaintDevice *pDevice = m_qtPainter->device();
if (height) *height = m_qtPainter->device()->heightMM();
int deviceWidthMM;
int deviceHeightMM;
if (pDevice)
{
deviceWidthMM = pDevice->widthMM();
deviceHeightMM = pDevice->heightMM();
}
else
{
deviceWidthMM = 0;
deviceHeightMM = 0;
}
if (width) *width = deviceWidthMM;
if (height) *height = deviceHeightMM;
} }
int wxQtDCImpl::GetDepth() const int wxQtDCImpl::GetDepth() const