Print Page | Close Window

destructor blows up

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=13955
Printed Date: 29 April 2024 at 2:58am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: destructor blows up
Posted By: adrien
Subject: destructor blows up
Date Posted: 08 April 2009 at 10:25pm
Hi
 
There's a problem with a report control I have, it blows up in its destructor when it tries to release the image manager.
 
Problem is, I've set the image manager for the control like this:
 
Ctrl.SetImageManager(XTPImageManager());
 
This sets it to the global static image manager which therefore must not be deleted.
 
The icons were originally added to the global static image manager by calling AddCustomIcon.  Does this put it in some other container or something?
 
I've tried copying the image manager, but if you use
 
 CXTPImageManager* pImageManager = new CXTPImageManager();
 pImageManager->AddIcons(XTPImageManager());
 Ctrl.SetImageManager(pImageManager);
 
then it loses the map of ID to icon,  It shouldn't since the code looks like it's trying to keep the ID.  I can see where it sets the custom icon into the map of m_mapImages at the custom ID point, so copying the list should work.
 
I also tried calling
 
Ctrl.SetImageManager(NULL)
 
prior to the destructor to try and get it to not delete the global static, but that doesn't work either. since it checks first to see if I'm passing in NULL.  It calls InternalRelease on it anyway so I suppose this will blow up as well.
 
p.s. I don't know why the Image Manager needs to be a CommandTarget.
 
It would be nice if instead you could just direct a control to use the global one instead of trying to take ownership of it.
 
 
 


-------------
http://www.wingate.com - http://www.wingate.com



Replies:
Posted By: adrien
Date Posted: 08 April 2009 at 10:28pm
in the end, I had to put the code
 
 CXTPImageManager* pImageManager = new CXTPImageManager();
 pImageManager->AddIcons(XTPImageManager());
 Ctrl.SetImageManager(pImageManager);
into my OnUpdate function (this is a ReportView).
 
this was so it could get the new icons added to the global.
 
Seems like a waste.   If you could just tell it to share the global list would be much more efficient.


-------------
http://www.wingate.com - http://www.wingate.com


Posted By: mdoubson
Date Posted: 08 April 2009 at 11:11pm
The question is - why you need more then one ImageManager? You can use many ImageList in one ImageManager if you properly add

//BOOL CXTPImageManager::SetImageList(UINT nBitmap, int cx, int nBaseCommand, COLORREF clrMask)

//CXTPImageManagerIcon* CXTPImageManager::GetImage(UINT nCommand, int nWidth = 16) const;

wndReport.GetImageManager()->SetImageList(IDB_ICONVIEWTEST, 32, 0, RGB(255, 0, 255));

wndReport.GetImageManager()->SetImageList(IDB_ICONVIEWTESTSMALL, 16, 1, RGB(255, 0, 255));



-------------
Mark Doubson, Ph.D.


Posted By: adrien
Date Posted: 09 April 2009 at 2:17am
I only want one image manager.,
 
But by default CXTPReportControl creates its own new one.
 
I want it to use the singleton global one, so I called SetImageManager(XTPImageManager())
 
that's when it started blowing up.
 
So yes, I only want there to be one, but the library wants one for every control so that it can delete it when it is deleted itself.


-------------
http://www.wingate.com - http://www.wingate.com


Posted By: adrien
Date Posted: 09 April 2009 at 2:18am
p.s. these icons came from the OS shell, there's no image list etc etc.

-------------
http://www.wingate.com - http://www.wingate.com


Posted By: mdoubson
Date Posted: 09 April 2009 at 10:00am
I totally not understand why having access to the source you are doing some guess, try and die steps instead of analyzing given source.

-------------
Mark Doubson, Ph.D.



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