Print Page | Close Window

Urgent: Crash after winmain exits!

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=12581
Printed Date: 11 May 2024 at 9:01am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Urgent: Crash after winmain exits!
Posted By: znakeeye
Subject: Urgent: Crash after winmain exits!
Date Posted: 31 October 2008 at 11:05am
We have a dialog that calls a function inside our OCX, showing a dialog. Inside this dialog I right-click to show a menu, and then dismiss the popup. After that, we exit our application (WM_COMMAND+IDCANCEL). When winmain exits, we get a crash at some AfxGetAmbientActCtx() call:
 
> mfc90d.dll!AfxGetAmbientActCtx()  Line 37 + 0xa bytes C++
  mfc90d.dll!AFX_MAINTAIN_STATE2::AFX_MAINTAIN_STATE2(AFX_MODULE_STATE * pNewState=0x07b1e4c8)  Line 86 + 0x5 bytes C++
  mfc90d.dll!CCmdTarget::InternalRelease()  Line 173 + 0x14 bytes C++
  ToolkitPro1201vc90D.dll!00c509c2()  
 
 
This is how the menu is shown (inside the dialog):
 
CXTPCommandBars* pCommandBars = (CXTPCommandBars*)CXTPCommandBars::CreateObject();
 if (pCommandBars)
 {
  pCommandBars->SetSite(this);
 
  CXTPPopupBar *pPopupBar = CXTPPopupBar::CreatePopupBar(pCommandBars);
  pPopupBar->LoadMenu(&RButtonMenu);
  pCommandBars->TrackPopupMenu(pPopupBar, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL, WindowPoint.x, WindowPoint.y, this);
  
  pCommandBars->InternalRelease();
  pPopupBar->InternalRelease();
 }
 
 



Replies:
Posted By: znakeeye
Date Posted: 31 October 2008 at 11:16am

Commenting the call to TrackPopupMenu removes the problem.  Hmmm?!



Posted By: Oleg
Date Posted: 31 October 2008 at 12:51pm
Hi,
 
Yes - inside ActiveX you need cleanup some Static objects manually.
 
call
CXTPPaintManager::Done()
and
XTPImageManager()->RemoveAll() in some ExitInstance.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: znakeeye
Date Posted: 13 February 2009 at 5:58am

Finally tested this code. Thank you, it works!



-------------
PokerMemento - http://www.pokermemento.com/


Posted By: rdhd
Date Posted: 17 July 2009 at 5:32pm
Is the crash due to CJ objects storing the module state data pointer?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net