Closing skinned app crashes in AfxGetAmbientActCtx |
Post Reply |
Author | ||
cjsnewbie
Groupie Joined: 24 October 2006 Status: Offline Points: 17 |
Post Options
Thanks(0)
Posted: 02 March 2009 at 3:48pm |
|
Hi,
I'm using Toolkit v12.1.1 with skinning like this: In constructor - XTPSkinManager()->LoadSkin(m_csStylesPath + _T("Vista.cjstyles") , _T("NORMALBLACK_INI")); Here is what I'm doing. I press one button on my main app dialog which opens new dialog window. This new dialog window class is derived from CDHtmlDialog MFC class. I close new dialog window by pressing 'X' (close button). Then, I close my main app. That is when I get this error: Call Stack:
I tried, XTPSkinManager()->LoadSkin(NULL, NULL); XTPSkinManager()->RemoveAll(); in main dialog's destructor. Didn't work. Any suggestion? Thanks. |
||
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
|
Hi,
Send it to support@codejock.com with sample that can help reproduce it.
|
||
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
||
cjsnewbie
Groupie Joined: 24 October 2006 Status: Offline Points: 17 |
Post Options
Thanks(0)
|
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
|
Please post the answer here when you've found the problem!
I've had similar crashes (in 12.1.1) at the very same line (AfxGetAmbientActCtx).
|
||
PokerMemento - http://www.pokermemento.com/
|
||
cjsnewbie
Groupie Joined: 24 October 2006 Status: Offline Points: 17 |
Post Options
Thanks(0)
|
|
Any update on this from support staff?
Will do. |
||
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
|
Btw, check out this thread: http://forum.codejock.com/forum_posts.asp?TID=12581
|
||
PokerMemento - http://www.pokermemento.com/
|
||
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
|
Hi,
I can't find issue number. What number was assigned ?
|
||
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
||
cjsnewbie
Groupie Joined: 24 October 2006 Status: Offline Points: 17 |
Post Options
Thanks(0)
|
|
Issue number? Is it something I should get in return for sending my sample project? I haven't received anything at all. Just for information, I added link to this thread in subject line of email. |
||
cjsnewbie
Groupie Joined: 24 October 2006 Status: Offline Points: 17 |
Post Options
Thanks(0)
|
|
Any update? It's been quite a while and I haven't heard anything back. |
||
Allover
Newbie Joined: 13 November 2007 Location: United States Status: Offline Points: 2 |
Post Options
Thanks(0)
|
|
Hi, we are using CodeJock Toolkit 13.1 and VS2008. Starting from after 12.0.1 we constantly receive an unhandled exception at AfxGetAmbientActCtx (called from CXTPSkinManager::RemoveAll) upon the application exit. Note that Toolkit 12.0.1 worked fine for us. The problem arises if we create a Wizard property sheet which resides in an external DLL (plug-in system for our application). Digging the Toolkit source we found that any dialog/property sheet and all their child windows will be hooked by CXTPSkinManager through CXTPSkinManager::HookWndProc. Each window will be associated with CXTPSkinObject. However, if a property sheet is created from another module (DLL) the hook function doesn't really work. (NOTE: we did not test this statement for dialogs/property sheets resided and created within the main EXE.) When the property sheet is closed all allocated CXTPSkinObject are not erased from the CXTPSkinManager map.
There are 2 solutions for this: 1. Call XTPSkinManager()->SetAutoApplyNewWindows(FALSE); 2. Each property sheet is derived from a class which keeps track over all child windows (one needs enumerating all windows within each property page including the property sheet itself). Upon exit from the property sheet (close, cancel etc.) one must remove ALL tracked windows manually from the SkinManager calling XTPSkinManager()->Remove(hWnd). This seems to solve the problem correctly for all our external property sheets. Is there any better solution for this matter? Best regards, Peter |
||
Peter
|
||
Insad
Groupie Joined: 28 October 2004 Location: The Netherlands Status: Offline Points: 55 |
Post Options
Thanks(0)
|
|
Hi,
We too still have this problem.
In our situation we have an EXE with the skinning enabled, has some windows etc. It calls a DLL which creates a dialog (which indeed shows the correct skin).
The code inside the DLL does not creates the skinmanager, but the dialog is derived from CXTResizeDialog.
When the dialog processing is done it is closed and the DLL ends. -- No problems until here
Then the EXE is closed (it has a dialog, derived from CXTResizeDialog, still showing, pressing the OK or Cancel on it ends the application)
-- Now the unhandled exception at AfxGetAmbientActCtx occours.
The options mentioned by Allover are not working / are not desirable.
Same question from me too: Is there a solution or a quick fix?
Best regards,
Albert van Peppen
|
||
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
|
Try cleaning up the skin manager in ExitInstance: CYourApp::ExitInstance()
{
XTPSkinManager()->LoadSkin(NULL, NULL);
XTPSkinManager()->RemoveAll(); |
||
PokerMemento - http://www.pokermemento.com/
|
||
Allover
Newbie Joined: 13 November 2007 Location: United States Status: Offline Points: 2 |
Post Options
Thanks(0)
|
|
The crash happens in CXTPSkinManager::RemoveAll(). It doesn't matter if you call XTPSkinManager()->RemoveAll() in ExitInstance or later. The problem can be described as follows.
1. You have a skinned application.
2. You have a dialog/wizard/property sheet created in a DLL (plug-in etc.).
3. For every dialog item a CXTPSkinObject will be allocated and added to the CXTPSkinManager map.
4. When the dialog is closed all allocated CXTPSkinObject are not erased from the CXTPSkinManager map and stay there alive with not valid CWnd pointers.
5. At any point after p.4 you call CXTPSkinManager::RemoveAll() the AfxGetAmbientActCtx will be thrown because the CXTPSkinManager tries to delete all allocated CXTPSkinObjects. Since the dialog is closed all controls do not exist anymore. However the corresponding CXTPSkinObjects are still alive. It seems that they must be destroyed just before the dialog and all its controls will be destroyed (HWNDs or CWnds should be still valid). It looks like this is a Windows hook callback problem or something like that which works fine with dialogs created within main EXE but the hook function pointer is lost in the calling chain (which seems to handle operations such as creation and destruction of windows) if a dialog created in a DLL file and is not properly called when you close such a dialog.
NOTE: our DLL files are plug-ins and loaded and unloaded by LoadLibrary, FreeLibrary. We don't know what happens with dialogs created in DLLs which are explicitly linked to the application.
|
||
Peter
|
||
Insad
Groupie Joined: 28 October 2004 Location: The Netherlands Status: Offline Points: 55 |
Post Options
Thanks(0)
|
|
Hi,
I assume you mean in the ExitInstance of the EXE.
The LoadSkin(NULL,NULL); is already in place and is the function that causes the crash.
Added the RemoveAll() will not add any value since the application is already crashed before reaching it
I was wondering:
Is there possibly something that needs to be done in the unload of the DLL or in the destroy of the dialog created in the DLL?
The crash does not occour when I don't call the dialog in the DLL: I do all initialisation in my DLL code but never create the Dialog and, as you would understand, don't call it :)
|
||
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
|
Wild guessing again... but please see this thread: http://forum.codejock.com/forum_posts.asp?TID=14933 What if your application receives WM_QUIT somehow and crash in a similar way as mine? Use Spy++ and look for it! (Not when debugging as this might hang your computer thoroughly!) |
||
PokerMemento - http://www.pokermemento.com/
|
||
Insad
Groupie Joined: 28 October 2004 Location: The Netherlands Status: Offline Points: 55 |
Post Options
Thanks(0)
|
|
Nope, no WM_QUIT message.
A simple testcase which fails:
Create a simple dialog based app, with skinning.
In the InitInstance skinning is enabled, a skin is loaded, a dialog is created, the DoModal() is done and the InitInstance returns FALSE.
In the ExitInstance i call the LoadSkin(NULL,NULL); --> This crashes!
Note that i check to see if skinning is Enabled before calling the LoadSkin(NULL,NULL);
The EXE-dialog has a button, and when pressed in loads a DLL (LoadLibraryEx/GetProcAddress/etc.) and calls a function in the DLL which creates a new dialog which just let you press OK or Cancel.
Then the Dialog in the DLL is destructed and the DLL terminates and is unloaded by the calling EXE.
When back in the EXE-dialog, you can press Cancel to exit the application.
I've tried several different skin-files; all fail. When providing NO skinfile, the InitInstance calls LoadSkin(NULL,NULL), and the application does not crash (hence: I am not calling the LoadSkin(NULL,NULL) when skinning is not enabled ; Using the function IsEnabled() in the skinmanager)
|
||
Products in use: XTP version 13.4.2/15.3.1/16.4.0/17.3.0
Platforms: Win2003(R2)/Win2008(R2)/Win7/Win2011/Win8(.1)/Win2012(R2)/Win10 (x86/x64) Langs: VC++ (MFC) 6/2005/2008/2013/2015/2017 |
||
Insad
Groupie Joined: 28 October 2004 Location: The Netherlands Status: Offline Points: 55 |
Post Options
Thanks(0)
|
|
Hi,
Sorry for bumping this post but it is still a major issue for us.
Currently we deliver our products with skinning disabled, but one of our key points where suppose to be the skinning possibilities.
The issue still happens in TKP 13.2.1.
The mentioned testcase is also still showing the issue.
Can/do I need to provide you with more information?
Thanks in advance.
|
||
Products in use: XTP version 13.4.2/15.3.1/16.4.0/17.3.0
Platforms: Win2003(R2)/Win2008(R2)/Win7/Win2011/Win8(.1)/Win2012(R2)/Win10 (x86/x64) Langs: VC++ (MFC) 6/2005/2008/2013/2015/2017 |
||
Smucker
Senior Member Joined: 02 February 2008 Status: Offline Points: 156 |
Post Options
Thanks(0)
|
|
I have seen several activation context problems and crashes caused by DLLs injected into the process (Logitech's SetPoint for example). I believe they no longer occur in my application because I statically link to Codejock and MFC.
See this thread for another example. Another possible workardound: if you're not running on Windows 9x/ME (where GDI and USER stuff leak systemwide), and have closed or flushed all your streams and database connections, using TerminateProcess() will result in a clean and quick application shutdown. |
||
Product: Xtreme Toolkit Pro version 13.2 (Unicode, static build)
Platform: Windows 200x/XP/Vista/Win7 (32/64 bit) Language: Visual C++ 9.0 (Studio 2008) |
||
mgampi
Senior Member Joined: 14 July 2003 Status: Offline Points: 1201 |
Post Options
Thanks(0)
|
|
Hello;
Has anyone every solved this problem? I'm using toolkit 15.3.1 and now I'm facing the same problem. In my case, static linking is no valid option. TIA Martin |
||
Martin Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
||
mgampi
Senior Member Joined: 14 July 2003 Status: Offline Points: 1201 |
Post Options
Thanks(0)
|
|
Still an issue!!
Eventually fixed in 17.3? |
||
Martin Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
||
astoyan
Admin Group Joined: 24 August 2013 Status: Offline Points: 304 |
Post Options
Thanks(0)
|
|
The initial issue should be fixed in 17.3 though you still need to make sure you call LoadSkin(NULL, NULL) prior to application exit. In 18.0 you won't need to do it.
The issue with WM_QUIT hasn't been reported for a while, I assume it's been fixed after 15.3.1 but cannot be sure. If you still can reproduce anything of that in the latest version please provide details or a sample, we'll try to fix it in 18.0. Regards, Alexander
|
||
mgampi
Senior Member Joined: 14 July 2003 Status: Offline Points: 1201 |
Post Options
Thanks(0)
|
|
Hi;
Just tested 17.3.0 and I can still get the error! It's all time reproducable! Take a skinned application Within the app call a exported C function into a regular DLL that opens a CXTPResizeDialog derived non modal dialog box. The XTPResizeDialog derived class contains a CXTPToolbar:
Whenever the app is closed after the dialog is shown I get the crash with this call stack:
When I do not create the toolbar (remove the lines of code above) the app closes without any crash. Any ideas or a workaround? Now it is really urgent, because release date is near and I have no other possibility to make huge design changes! |
||
Martin Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
||
Insad
Groupie Joined: 28 October 2004 Location: The Netherlands Status: Offline Points: 55 |
Post Options
Thanks(0)
|
|
Hi,
We still have the problem when we enable the possibility for the user to select his own theme/style. Our work around is that we have selected a fixes theme/style and have disabled the functionality that the user can switch his theme/style. Not as good as we hoped for, but in small, simple sample applications we can't get it to reproduce. Possibly it has something to do with the fact that we use multi threading and somewhere a handle is used from the wrong thread or something? We did have that problem with MAPI as well but here we managed to solve this ;) We test to see the problem is resolved in each release from TKP but so far no luck. But we have high hopes for v18.0, if it ever gets released.. |
||
Products in use: XTP version 13.4.2/15.3.1/16.4.0/17.3.0
Platforms: Win2003(R2)/Win2008(R2)/Win7/Win2011/Win8(.1)/Win2012(R2)/Win10 (x86/x64) Langs: VC++ (MFC) 6/2005/2008/2013/2015/2017 |
||
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 |