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

CXTPImageManagerIconHandle bug!

 Post Reply Post Reply
Author
Message
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Topic: CXTPImageManagerIconHandle bug!
    Posted: 02 September 2008 at 4:14am
CXTPImageManagerIconHandle foo()
{
    CXTPImageManagerIconHandle hIcon;
    hIcon = ...
   
    return hIcon; // Destructor called for hIcon
}
 
hIcon.m_bClearHandles == TRUE... so the returned object will be corrupted. I believe you should use auto_ptr-thinking here!
 
In copy-constructor and assignment-operator the right-hand-side variable m_bClearHandles should be set to FALSE!
 
h1 = h2; // h2.m_bClearHandles = FALSE
 
My solution:
mutable BOOL m_bClearHandles;
 
CXTPImageManagerIconHandle::CXTPImageManagerIconHandle(const CXTPImageManagerIconHandle& hHandle)
{
    ...
    hHandle.m_bClearHandles = FALSE;
}
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 08 September 2008 at 3:27am
Hi,
 
Its'wrong. Don't change it.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 09 September 2008 at 2:43pm
I disagree. The class is broken since it cannot be returned without destroying the icon.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 09 September 2008 at 2:56pm
Hi,
you can change it but you will get a lot of resource leaks.
 
better change your method to get reference
 
bool foo(CXTPImageManagerIconHandle& out)
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
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.188 seconds.