Print Page | Close Window

CXTPImageManagerIconHandle copy constructor

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
Printed Date: 01 March 2024 at 9:16am
Software Version: Web Wiz Forums 12.04 -

Topic: CXTPImageManagerIconHandle copy constructor
Posted By: Julianis
Subject: CXTPImageManagerIconHandle copy constructor
Date 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

// 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 ?


Posted By: astoyan
Date 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.


Posted By: Julianis
Date Posted: 09 March 2022 at 10:17am
Ok, thanks for the informations.


Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 -
Copyright ©2001-2021 Web Wiz Ltd. -