Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Skin Framework
  New Posts New Posts RSS Feed - using skinframe in DLL, crash when exits
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

using skinframe in DLL, crash when exits

 Post Reply Post Reply
Author
Message
lyonwhl View Drop Down
Newbie
Newbie


Joined: 14 August 2008
Location: China
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote lyonwhl Quote  Post ReplyReply Direct Link To This Post Topic: using skinframe in DLL, crash when exits
    Posted: 19 November 2008 at 8:28pm
Hi,
   I want to use skinframe to decorate my own dialog in regular MFC DLL. Everything is ok in runtime . But when the main application exits, it crashes. The error happends in the file "afxwinl.inl" ,line 37 "{  return afxAmbientActCtx; }", and the tip is "0x0000005 clashing happens when reading 0x1003c770".
   On the other hand, if the main application call the own dialog directly, there is no problem.
   By the way, if the main application use my own dialog firstly and DLL use it later, no error happens.
   I  appreciate any help.
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: 20 November 2008 at 2:01am
Hello,
 
Remove all objects in ExitInstance of your dll:
 
XTPSkinManager()->LoadSkin(NULL, NULL);
XTPSkinManager()->RemoveAll();
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: 05 January 2009 at 6:52am
I'm encountering a similar problem, but with no skinning at all. Is there a similar principle for commandbars and menus?
 
We get the crash after this code has been executed:
 
CXTPCommandBars* pCommandBars = (CXTPCommandBars*)CXTPCommandBars::CreateObject();
if (pCommandBars)
{
    pCommandBars->SetSite(this);
    CXTPPopupBar *pPopupBar = CXTPPopupBar::CreatePopupBar(pCommandBars);
    CXTPControlButton *pButton = (CXTPControlButton*)pPopupBar->GetControls()->Add(xtpControlButton, 1000);
    pButton->SetCaption("Test");
    pCommandBars->TrackPopupMenu(pPopupBar, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL, point.x, point.y, this);
    pPopupBar->InternalRelease();
    pCommandBars->InternalRelease();
}
 
PokerMemento - http://www.pokermemento.com/
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: 06 January 2009 at 1:45am
Hi,
Looks like right core. What lines give crush ?
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: 06 January 2009 at 8:38am
The crash happens after the OCX has unloaded. It's so weird!
 
I've tried to make a sample project where this would happen, but it doesn't. Here's the structure:
 
EXE initializes OCX. Then a member function is called where a dialog is shown (the OCX is dependent on ToolkitPro). In this dialog we run the code above, displaying a menu. As soon as this menu has been shown (nothing more), we get a crash when we press "Cancel" in this dialog (effectively exiting the application).
 
It's crazy. But if we use a normal menu, the problem goes away.
PokerMemento - http://www.pokermemento.com/
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: 07 January 2009 at 3:02pm
Hi,
 
Such things need to debug :( Please try reproduce it again .
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 886
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Posted: 17 July 2009 at 5:41pm
I had this exact same problem. The problem is that CJ is grabbing and storing the module state data pointer and accessing it after your ocx (dll) unloads. I debugged this some time ago (june last year) and I put this comment in my code:
 

CodeJock is loading an image file. When that happens CJ creates some CCmdTarget object

// and that object grabs and stores the module state data pointer. Later when unloading, the CJ object accesses it. The issue

// is that the list control DLL can unload before the CJ (toolkitpro) DLL.

It appears to me that CJ thinks it is grabbing its own module state data. There is no reason I know of for CJ to store your (or my) OCX module state data. To avoid the crash in my app, I had to swap out my OCX module state data with that of my application since it is one of the last modules to unload.
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.