From 44611572b5e353ff9df1316b26f3ea6c3456cdac Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 13 Mar 2014 16:19:55 +0000 Subject: [PATCH] Fix resource leak in wxMSW wxStaticBitmap when using RGBA icons. Release the old handle if it wasn't freed by STM_SETIMAGE itself. Closes #16068. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@76141 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/msw/statbmp.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 6e358363d8..6cfa969ff0 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -643,6 +643,7 @@ wxMSW: - Fix width of the vertical toolbars (Artur Wieczorek). - Fix handling of controls in the vertical toolbars (Artur Wieczorek). - Fix loading of top to bottom BMP files in wxBitmap (Artur Wieczorek). +- Fix resource leak in wxStaticBitmap with RGBA icons (Artur Wieczorek). wxOSX: diff --git a/src/msw/statbmp.cpp b/src/msw/statbmp.cpp index 77e8df1aff..7296920f7b 100644 --- a/src/msw/statbmp.cpp +++ b/src/msw/statbmp.cpp @@ -294,10 +294,10 @@ void wxStaticBitmap::SetImageNoCopy( wxGDIImage* image) m_isIcon ? IMAGE_ICON : IMAGE_BITMAP, (LPARAM)handle); // detect if this is still the handle we passed before or // if the static-control made a copy of the bitmap! - if (m_currentHandle != 0 && oldHandle != (HGDIOBJ) m_currentHandle) + if (oldHandle != 0 && oldHandle != (HGDIOBJ) m_currentHandle) { // the static control made a copy and we are responsible for deleting it - DeleteObject((HGDIOBJ) oldHandle); + ::DeleteObject((HGDIOBJ) oldHandle); } // Save bitmap handle only if it's not a temporary one, otherwise it's