Fix wxMenuItem::SetBitmap infinite recursion (Vista+).
Calling a menu item's SetBitmap can result in a stack overflow. This occurs when setting a bitmap after the menu item has already been added to the menu and while running under Vista (and later). Under those circumstances [Do]SetBitmap will call GetHBitmapForMenu which itself calls SetBitmap again. Fix by adding a simple check for re-entry. Regression since r76202. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76754 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -88,6 +88,7 @@ private:
|
||||
CPPUNIT_TEST( Labels );
|
||||
CPPUNIT_TEST( RadioItems );
|
||||
CPPUNIT_TEST( RemoveAdd );
|
||||
CPPUNIT_TEST( ChangeBitmap );
|
||||
WXUISIM_TEST( Events );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
@@ -100,6 +101,7 @@ private:
|
||||
void Labels();
|
||||
void RadioItems();
|
||||
void RemoveAdd();
|
||||
void ChangeBitmap();
|
||||
void Events();
|
||||
|
||||
wxFrame* m_frame;
|
||||
@@ -405,6 +407,22 @@ void MenuTestCase::RemoveAdd()
|
||||
menu0->Delete(item);
|
||||
}
|
||||
|
||||
void MenuTestCase::ChangeBitmap()
|
||||
{
|
||||
wxMenu *menu = new wxMenu;
|
||||
|
||||
wxMenuItem *item = new wxMenuItem(menu, wxID_ANY, "Item");
|
||||
menu->Append(item);
|
||||
|
||||
// On Windows Vista (and later) calling SetBitmap, *after* the menu
|
||||
// item has already been added, used to result in a stack overflow:
|
||||
// [Do]SetBitmap can call GetHBitmapForMenu which will call SetBitmap
|
||||
// again etc...
|
||||
item->SetBitmap( wxBitmap(1, 1) );
|
||||
|
||||
wxDELETE(menu);
|
||||
}
|
||||
|
||||
void MenuTestCase::Events()
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
|
Reference in New Issue
Block a user