[ wxwindows-Bugs-1538621 ] wxMSW: wxMenu::DoInsertOrAppend() doesn't honor enabled stat

SourceForge.net noreply at sourceforge.net
Fri Aug 11 04:19:30 PDT 2006


Bugs item #1538621, was opened at 2006-08-11 13:19
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1538621&group_id=9863

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: wxMSW specific
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Christian Walther (cwalther)
Assigned to: Nobody/Anonymous (nobody)
Summary: wxMSW: wxMenu::DoInsertOrAppend() doesn't honor enabled stat

Initial Comment:
This is a bug I observed in wxMSW 2.6.3, though I
didn't find any relevant changes in CVS, so I suppose
it applies to CVS as well.

Consider the following code:

wxMenu *menu = new wxMenu();
wxMenuItem *item = new wxMenuItem(menu, wxID_ANY,
wxT("item"));
//item->Enable(false); //produces an error message,
which it shouldn't IMHO, but that's another matter

menu->Append(item);
item->Enable(false);
PopupMenu(menu);
menu->Remove(item);

menu->Append(item);
//item->Enable(true); //(B)
//item->Enable(false); //(A)
PopupMenu(menu);
menu->Remove(item);

Expected result: Both times the menu is shown, the item
should be disabled.

Actual result: The item is disabled the first time, but
enabled the second. Uncommenting the line marked (A)
doesn't change anything (because the item still thinks
it's disabled and therefore immediately returns from
Enable(false) without doing anything). Only
uncommenting both lines (A) and (B) works around the bug.

The cause is that the wxMenu::DoInsertOrAppend() method
doesn't honor the enabled state of the wxMenuItem being
added, it always adds it as an enabled item. To fix
this, I propose the attached patch against
src/msw/menu.cpp (current revision 1.136).

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1538621&group_id=9863




More information about the wx-dev mailing list