CXTPImageManagerIconHandle copy constructor |
Post Reply |
Author | |
Julianis
Newbie Joined: 23 March 2017 Status: Offline Points: 3 |
Post Options
Thanks(0)
Posted: 22 February 2022 at 10:36am |
We noticed that when using CXTPImageManagerIconHandle, the copy constructor doesnt duplicate the handles when copying from a non shared handle:
CXTPImageManagerIconHandle A; // loads a HBITMAP in A, A.m_bClearHandles set to TRUE A.CreateIconFromResource(MAKEINTRESOURCE(ID_XXXX), CSize(32, 32));// copy constructor, members are simply copied, so handle from A ends up in B // but B.m_bClearHandles = FALSE CXTPImageManagerIconHandle B(A); // frees up handle A.Clear(); // at this stage B still reference an invalid HBITMAP I just modifed the copy constructor to call CopyHandle() if (hHandle.m_bClearHandles == TRUE) Is it a bug or is there a design issue i missed ? Regards |
|
astoyan
Admin Group Joined: 24 August 2013 Status: Offline Points: 304 |
Post Options
Thanks(0)
|
It is definitely a bad design, but it was necessary to do so in order to preserve the backward compatibility with the legacy class implementation that did not support various icon types. Fixing that behavior in constructor will lead to a lot more problems for those who has lots of dependencies on that class for a while.
Regards, Alexander
|
|
Julianis
Newbie Joined: 23 March 2017 Status: Offline Points: 3 |
Post Options
Thanks(0)
|
Ok, thanks for the informations.
Regards |
|
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 |