X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5c96c8649e6edeccbcd6aa40fdfa4da2e6ab5b59..4681a3ea0d0502ec7a787bc4dd24e43718a02b7c:/src/msw/imaglist.cpp diff --git a/src/msw/imaglist.cpp b/src/msw/imaglist.cpp index 087d6dddba..366e635f9e 100644 --- a/src/msw/imaglist.cpp +++ b/src/msw/imaglist.cpp @@ -159,7 +159,7 @@ int wxImageList::Add(const wxBitmap& bitmap, const wxBitmap& mask) #endif // wxUSE_WXDIB && wxUSE_IMAGE hbmp = GetHbitmapOf(bitmap); - HBITMAP hbmpMask = GetMaskForImage(bitmap, mask); + AutoHBITMAP hbmpMask(GetMaskForImage(bitmap, mask)); int index = ImageList_Add(GetHImageList(), hbmp, hbmpMask); if ( index == -1 ) @@ -167,8 +167,6 @@ int wxImageList::Add(const wxBitmap& bitmap, const wxBitmap& mask) wxLogError(_("Couldn't add an image to the image list.")); } - ::DeleteObject(hbmpMask); - return index; } @@ -237,17 +235,15 @@ bool wxImageList::Replace(int index, #endif // wxUSE_WXDIB && wxUSE_IMAGE hbmp = GetHbitmapOf(bitmap); - HBITMAP hbmpMask = GetMaskForImage(bitmap, mask); + AutoHBITMAP hbmpMask(GetMaskForImage(bitmap, mask)); - bool ok = ImageList_Replace(GetHImageList(), index, hbmp, hbmpMask) != 0; - if ( !ok ) + if ( !ImageList_Replace(GetHImageList(), index, hbmp, hbmpMask) ) { wxLogLastError(wxT("ImageList_Replace()")); + return false; } - ::DeleteObject(hbmpMask); - - return ok; + return true; } // Replaces a bitmap and mask from an icon.