destructor blows up |
Post Reply |
Author | |
adrien
Senior Member Joined: 30 April 2007 Location: New Zealand Status: Offline Points: 449 |
Post Options
Thanks(0)
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.
|
|
adrien
Senior Member Joined: 30 April 2007 Location: New Zealand Status: Offline Points: 449 |
Post Options
Thanks(0)
|
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.
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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)); |
|
adrien
Senior Member Joined: 30 April 2007 Location: New Zealand Status: Offline Points: 449 |
Post Options
Thanks(0)
|
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.
|
|
adrien
Senior Member Joined: 30 April 2007 Location: New Zealand Status: Offline Points: 449 |
Post Options
Thanks(0)
|
p.s. these icons came from the OS shell, there's no image list etc etc.
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
I totally not understand why having access to the source you are doing some guess, try and die steps instead of analyzing given source.
|
|
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 |