Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CXTPImageManagerIconHandle copy constructor
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPImageManagerIconHandle copy constructor

 Post Reply Post Reply
Author
Message
Julianis View Drop Down
Newbie
Newbie


Joined: 23 March 2017
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Julianis Quote  Post ReplyReply Direct Link To This Post Topic: CXTPImageManagerIconHandle copy constructor
    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
Back to Top
astoyan View Drop Down
Admin Group
Admin Group
Avatar

Joined: 24 August 2013
Status: Offline
Points: 304
Post Options Post Options   Thanks (0) Thanks(0)   Quote astoyan Quote  Post ReplyReply Direct Link To This Post Posted: 08 March 2022 at 11:59am
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
Back to Top
Julianis View Drop Down
Newbie
Newbie


Joined: 23 March 2017
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Julianis Quote  Post ReplyReply Direct Link To This Post Posted: 09 March 2022 at 10:17am
Ok, thanks for the informations.

Regards
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.328 seconds.