Ensure that menu item HBITMAPs live for long enough
We must keep storing the currently used bitmap in wxMSW wxMenuItem to ensure that its HBITMAP remains valid, as keeping wxBitmapBundle is not enough: it may not preserve the bitmap at all (if it generates it on demand, for example), and we may also use a different bitmap from what we get from it (e.g. we convert mask to alpha).
This commit is contained in:
@@ -1369,8 +1369,12 @@ HBITMAP wxMenuItem::GetHBitmapForMenu(BitmapKind kind) const
|
||||
#if wxUSE_IMAGE
|
||||
if ( wxGetWinVersion() >= wxWinVersion_Vista )
|
||||
{
|
||||
// We need to store the returned bitmap, so that its HBITMAP remains
|
||||
// valid for as long as it's used.
|
||||
bool checked = (kind != Unchecked);
|
||||
wxBitmap bmp = GetBitmap(checked);
|
||||
wxBitmap& bmp = const_cast<wxBitmap&>(checked ? m_bmpCheckedCurrent
|
||||
: m_bmpUncheckedCurrent);
|
||||
bmp = GetBitmap(checked);
|
||||
if ( bmp.IsOk() )
|
||||
{
|
||||
return GetHbitmapOf(bmp);
|
||||
|
||||
Reference in New Issue
Block a user