Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - destructor blows up
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

destructor blows up

 Post Reply Post Reply
Author
Message
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Topic: destructor blows up
    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.
 
 
 
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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));

Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Posted: 09 April 2009 at 2:18am
p.s. these icons came from the OS shell, there's no image list etc etc.
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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.
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.141 seconds.