Add RAII AutoIconInfo class wrapping ICONINFO Windows struct.
This ensures that we never forget to delete the handles returned by GetIconInfo() and also centralizes the error message given if it fails in a single place. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78132 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -663,12 +663,8 @@ wxSize wxGetHiconSize(HICON WXUNUSED_IN_WINCE(hicon))
|
||||
#ifndef __WXWINCE__
|
||||
if ( hicon )
|
||||
{
|
||||
ICONINFO info;
|
||||
if ( !::GetIconInfo(hicon, &info) )
|
||||
{
|
||||
wxLogLastError(wxT("GetIconInfo"));
|
||||
}
|
||||
else
|
||||
AutoIconInfo info;
|
||||
if ( info.GetFrom(hicon) )
|
||||
{
|
||||
HBITMAP hbmp = info.hbmMask;
|
||||
if ( hbmp )
|
||||
@@ -678,11 +674,7 @@ wxSize wxGetHiconSize(HICON WXUNUSED_IN_WINCE(hicon))
|
||||
{
|
||||
size = wxSize(bm.bmWidth, bm.bmHeight);
|
||||
}
|
||||
|
||||
::DeleteObject(info.hbmMask);
|
||||
}
|
||||
if ( info.hbmColor )
|
||||
::DeleteObject(info.hbmColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user