Print Page | Close Window

using skinframe in DLL, crash when exits

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Skin Framework
Forum Description: Topics Related to Codejock Skin Framework
URL: http://forum.codejock.com/forum_posts.asp?TID=12732
Printed Date: 22 November 2024 at 6:36pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: using skinframe in DLL, crash when exits
Posted By: lyonwhl
Subject: using skinframe in DLL, crash when exits
Date 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.



Replies:
Posted By: Oleg
Date 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


Posted By: znakeeye
Date 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/


Posted By: Oleg
Date Posted: 06 January 2009 at 1:45am
Hi,
Looks like right core. What lines give crush ?


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


Posted By: znakeeye
Date 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/


Posted By: Oleg
Date Posted: 07 January 2009 at 3:02pm
Hi,
 
Such things need to debug :( Please try reproduce it again .


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


Posted By: rdhd
Date 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.



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