Delete cached wxImageFileProperty bitmap if required size changed

Rescaled bitmap should be cached as long as the required size remains
unchanged.
This commit is contained in:
Artur Wieczorek
2020-04-12 18:32:15 +02:00
parent f31b9b27f4
commit 799f245149

View File

@@ -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 );