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:
@@ -2375,15 +2375,17 @@ static wxImage LoadImageFromResource(const wxString &name, wxBitmapType type)
|
||||
}
|
||||
else
|
||||
{
|
||||
ICONINFO info;
|
||||
if ( !::GetIconInfo(hIcon, &info) )
|
||||
{
|
||||
wxLogLastError(wxT("GetIconInfo"));
|
||||
AutoIconInfo info;
|
||||
if ( !info.GetFrom(hIcon) )
|
||||
return wxImage();
|
||||
}
|
||||
|
||||
hBitmap.Init(info.hbmColor);
|
||||
hMask.Init(info.hbmMask);
|
||||
|
||||
// Reset the fields to prevent them from being destroyed, we took
|
||||
// ownership of them.
|
||||
info.hbmColor =
|
||||
info.hbmMask = 0;
|
||||
}
|
||||
}
|
||||
else if ( type == wxBITMAP_TYPE_CUR_RESOURCE )
|
||||
|
||||
Reference in New Issue
Block a user