Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Urgent: Crash after winmain exits!
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Urgent: Crash after winmain exits!

 Post Reply Post Reply
Author
Message
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Topic: Urgent: Crash after winmain exits!
    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();
 }
 
 
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 31 October 2008 at 11:16am

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

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 13 February 2009 at 5:58am

Finally tested this code. Thank you, it works!

PokerMemento - http://www.pokermemento.com/
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 867
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Posted: 17 July 2009 at 5:32pm
Is the crash due to CJ objects storing the module state data pointer?
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.