ABX wrote:1. Which wxWidgest it is related to.
Basically, it relies to the versions 2.53, 2.55 and the CVS version, but I catched an access violation using ver.2.55 and in ver.2.53 my code worked without the AV.
ABX wrote:2. How core developer could duplicate the crash.
3. Perhaps explanation why you think this is best place for fixing crash (ie. link to msdn or something if possible)
I will explain. MSDN says
The following groups of flags cannot be used together:
* MF_BYCOMMAND and MF_BYPOSITION
* MF_DISABLED, MF_ENABLED, and MF_GRAYED
* MF_BITMAP, MF_STRING, MF_OWNERDRAW, and MF_SEPARATOR
And in wxWidges there is ability to set both MF_STRING and MF_OWNERDRAW in the same time.
It's possible to reproduce this in following way.
1. Create a menu having bitmaps. In this case by default the ms_nDefaultMarginWidth static member is 15 but MarginWidth for bitmap items is 16 and correspondently ms_nLastMarginWidth is 16 too.
2. Create a new menu item and it will have m_bOwnerDrawn = true because, the ResetOwnerDrawn() method is called before SetMarginWidth(GetMarginWidth()) in the wxMenuItem::Init method.
3. Now I wish to reset the m_bOwnerDrawn flag of the created menu item and reset the MF_OWNERDRAW flag using the following code
Code: Select all
wxMenuItem *pItem = Menu->AppendRadioItem(...);
const wxString str = pItem->GetText();
Ok... Now we have both the flags are set and a string pointer as info.dwTypeData in wxMenuItem::SetText method. The result is Windows calls WM_MEASUREITEM and pMeasureStruct->itemData points to the string and not to a wxMenuItem instance but statically casts to wxMenuItem in the wxWindowMSW::MSWOnMeasureItem method.