diff --git a/include/wx/propgrid/advprops.h b/include/wx/propgrid/advprops.h index e3aa6dc6f0..0889778957 100644 --- a/include/wx/propgrid/advprops.h +++ b/include/wx/propgrid/advprops.h @@ -296,11 +296,11 @@ public: const wxRect& rect, wxPGPaintData& paintdata ) wxOVERRIDE; protected: - wxBitmap* m_pBitmap; // final thumbnail area - wxImage* m_pImage; // intermediate thumbnail area + wxBitmap m_bitmap; // final thumbnail area + wxImage m_image; // intermediate thumbnail area private: - // Initialize m_pImage using the current file name. + // Initialize m_image using the current file name. void LoadImageFromFile(); }; diff --git a/interface/wx/propgrid/advprops.h b/interface/wx/propgrid/advprops.h index ca02d50001..3dd7542aef 100644 --- a/interface/wx/propgrid/advprops.h +++ b/interface/wx/propgrid/advprops.h @@ -250,8 +250,8 @@ public: const wxRect& rect, wxPGPaintData& paintdata ); protected: - wxBitmap* m_pBitmap; // final thumbnail area - wxImage* m_pImage; // intermediate thumbnail area + wxBitmap m_bitmap; // final thumbnail area + wxImage m_image; // intermediate thumbnail area }; diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index 37bdd429c8..994c74b338 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -1838,18 +1838,11 @@ wxImageFileProperty::wxImageFileProperty( const wxString& label, const wxString& { m_wildcard = wxPGGetDefaultImageWildcard(); - m_pImage = NULL; - m_pBitmap = NULL; - LoadImageFromFile(); } wxImageFileProperty::~wxImageFileProperty() { - if ( m_pBitmap ) - delete m_pBitmap; - if ( m_pImage ) - delete m_pImage; } void wxImageFileProperty::OnSetValue() @@ -1857,8 +1850,8 @@ void wxImageFileProperty::OnSetValue() wxFileProperty::OnSetValue(); // Delete old image - wxDELETE(m_pImage); - wxDELETE(m_pBitmap); + m_image = wxNullImage; + m_bitmap = wxNullBitmap; LoadImageFromFile(); } @@ -1870,7 +1863,7 @@ void wxImageFileProperty::LoadImageFromFile() // Create the image thumbnail if ( filename.FileExists() ) { - m_pImage = new wxImage( filename.GetFullPath() ); + m_image.LoadFile(filename.GetFullPath()); } } @@ -1883,25 +1876,24 @@ void wxImageFileProperty::OnCustomPaint( wxDC& dc, const wxRect& rect, wxPGPaintData& ) { - if ( m_pBitmap || (m_pImage && m_pImage->IsOk() ) ) + if ( m_bitmap.IsOk() || m_image.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) ) + if ( m_bitmap.IsOk() && (m_bitmap.GetWidth() != rect.width || m_bitmap.GetHeight() != rect.height) ) { - delete m_pBitmap; - m_pBitmap = NULL; + m_bitmap = wxNullBitmap; } - if ( !m_pBitmap ) + if ( !m_bitmap.IsOk() ) { - m_pImage->Rescale( rect.width, rect.height ); - m_pBitmap = new wxBitmap( *m_pImage ); + m_image.Rescale( rect.width, rect.height ); + m_bitmap = wxBitmap(m_image, dc); } - dc.DrawBitmap( *m_pBitmap, rect.x, rect.y, false ); + dc.DrawBitmap( m_bitmap, rect.x, rect.y, false ); } else {