From 799f24514971516dba423fb53a12181302beae3b Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 12 Apr 2020 18:32:15 +0200 Subject: [PATCH] Delete cached wxImageFileProperty bitmap if required size changed Rescaled bitmap should be cached as long as the required size remains unchanged. --- src/propgrid/advprops.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index 0d545800d3..77d6202d08 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -1889,13 +1889,19 @@ void wxImageFileProperty::OnCustomPaint( wxDC& dc, if ( m_pBitmap || (m_pImage && m_pImage->IsOk() ) ) { // Draw the thumbnail - // Create the bitmap here because required size is not known in OnSetValue(). + + // Delete the cache if required size changed + if ( m_pBitmap && (m_pBitmap->GetWidth() != rect.width || m_pBitmap->GetHeight() != rect.height) ) + { + delete m_pBitmap; + m_pBitmap = NULL; + } + if ( !m_pBitmap ) { m_pImage->Rescale( rect.width, rect.height ); m_pBitmap = new wxBitmap( *m_pImage ); - wxDELETE(m_pImage); } dc.DrawBitmap( *m_pBitmap, rect.x, rect.y, false );