Print Page | Close Window

Module state data problem

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=10926
Printed Date: 27 February 2025 at 6:27pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Module state data problem
Posted By: rdhd
Subject: Module state data problem
Date Posted: 05 June 2008 at 2:52pm
When tracking a popup menu, we are finding that the code can call LoadImage on one of the theme objects. When it does, it creates an image object (in my case CXTPOffice2007Images object).
 
The image object is derived from CCmdTarget. When created, CCmdTarget obtains the current module state data pointer and directly stores it in instance data.
 
Then the CJ code that created the image object stores the object in an array. Later when the toolkitpro DLL unloads, all of these objects are disposed of.
 
So now we have a race condition where the order that DLLs unload becomes an issue. If the module that was active when the image was created is unloaded before the toolkitpro module, MFC can crash when the CCmdTarget object is given its release from the codejock images (removeall?) method.
 
Shouldn't the CodeJock code make sure that if it creates and stores a CCmdTarget based CodeJock object that before creating the object the codejock module state should be made the active module state? Otherwise, how can we robustly prevent crashes during shutdown?



Replies:
Posted By: Oleg
Date Posted: 06 June 2008 at 1:08am
Hi,
 
Think you can call manually XTPOffice2007Images()->RemoveAll(); in some ExitInstance of your module.


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


Posted By: rdhd
Date Posted: 17 July 2009 at 6:56pm
Oleg,
 
Has V13 stopped storing the objects or at least quit waiting until dll unload to let them go?



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