![]() |
Access violation CXTPMenuBar::LoadMenu |
Post Reply ![]() |
Author | |
franji1 ![]() Groupie ![]() ![]() Joined: 28 June 2005 Status: Offline Points: 70 |
![]() ![]() ![]() ![]() ![]() Posted: 28 October 2005 at 10:59am |
XTP V 8.60 The current menu is still being displayed, but the LoadMenu call starts dealing with loading the new one, the old controls are invalid. CXTPControl * items in the the CXTPControls::m_arrControls array are invalid. The pointers are valid, but what they point to is invalid (lots of 0xfeeefeee in debug build). It appears it is dealing with controls that no longer exist, but are still in the container. It actually crashes in the CXTPControls::CalcDynamicSize method when it attempts to call a method with one of these invalid CXTPControl * pointers: CSize CXTPControls::CalcDynamicSize(CDC* pDC, int nLength, DWORD dwMode, const CRect& rcBorder, int nWidth) Here's the call stack from my OnInitMenu method (at the bottom) to the crash (at the top). Any ideas on how to fix this would be very helpful!! > HEIXTP86d.dll!CXTPControls::CalcDynamicSize(CDC * pDC=0x0012c894, int nLength=952, unsigned long dwMode=11, const CRect & rcBorder={...}, int nWidth=0) Line 827 + 0x26 C++ |
|
![]() |
|
franji1 ![]() Groupie ![]() ![]() Joined: 28 June 2005 Status: Offline Points: 70 |
![]() ![]() ![]() ![]() ![]() |
I figured out a "fix". You'll notice that we are calling CXTPControls::RemoveAll. This method basically cleans up the XTP Controls associated with the menu bar. There is some smart code here: void CXTPControls::RemoveAll(void) ORIGINAL CODE All references between the container and the menu bar should have been taken care of before the call to InteralRelease (where it's initialyzing the two pointers to NULL). But for some reason, the InternalRelease call ends up accessing the same container way down the stack in the CXTPControls::CalcDynamicSize method (I checked the pointer of the CXTPControls this pointer, and they match). I rewrote the CXTPControls::RemoveAll method to basically copy the control pointers into a temporary automatic CArray<CXTPControl*, CXTPControl*> array, call RemoveAll on the CXTPControls::m_arrControls before the loop, then loop through the temporary array. Here's the new code, but I am not 100% sure if it causes any side effects: void CXTPControls::RemoveAll(void) NEW CODE m_arrControls.RemoveAll(); // clear out member container Anyone want to comment?? |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hello, Can you uattach sample to show what you do to replace menu? |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
franji1 ![]() Groupie ![]() ![]() Joined: 28 June 2005 Status: Offline Points: 70 |
![]() ![]() ![]() ![]() ![]() |
This is the method that calls the LoadMenu method on the MenuBar object (at the bottom of the method). Below this method is the OnActivateView method which void CProgramFrameD::OnInitMenu(CMenu* pMenu) BroadcastProgramMessage(ONINITMENU, (LPARAM) this, (LPARAM) pMenu); // Doug 6/14/05 - Don't update the XTPro Menu here. Otherwise, we } Here's the method that "calls" OnInitMenu for the specific view in question (other views have similar structure). Only the "CLadView" has an accelerator key assigned to it (Ctrl+L) to bring it up. It only crashes when it must create the view. It does not crash if the view already exists and we are only changing focus to that existing view. void CLadView::OnActivateView( BOOL bActivate, CView* pActivateView, CView* pDeactiveView) if( InEditMode() ) ::SendMessage(pFrame->m_hWndMDIClient, WM_MDISETMENU, (WPARAM)pLDC->hSharedMenu, GetProgramFrame()->SendMessage(WM_INITMENU, (WPARAM)pLDC->hSharedMenu, 0); |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |