Possible bug? (4.2)
Chris Scott -- cscott@aceltd.com Thursday, August 01, 1996 Enviroment: Visual C++ 4.2, NT 4.0 Beta 2 I recently recompiled my application under VC++ 4.2 and found that it was suddenly leaking ImageLists. Here's the error: Detected memory leaks! Dumping objects -> winctrl2.cpp(515) : {8195} client block at 0x0054AEA0, subtype 0, 8 bytes long. a CImageList object at $0054AEA0, 8 bytes long More specifically, CListCtrl::CreateDragImage() and CTreeCtrl::CreateDragImage() are the culprits. The functions return a pointer to an ImageList, but nowhere in the 4.2 docs does it say that I need to delete the memory. Besides, this worked fine under 4.1. Is anyone else running into this? - Chris Scott
Mike Blaszczak -- mikeblas@nwlink.com Monday, August 05, 1996 [Mini-digest: 2 responses] At 06:20 AM 8/1/96 -0400, you wrote: >Enviroment: Visual C++ 4.2, NT 4.0 Beta 2 >I recently recompiled my application under VC++ 4.2 and found that it was >suddenly leaking ImageLists. >Here's the error: >Detected memory leaks! >Dumping objects -> >winctrl2.cpp(515) : {8195} client block at 0x0054AEA0, subtype 0, 8 bytes >long. >a CImageList object at $0054AEA0, 8 bytes long >More specifically, CListCtrl::CreateDragImage() and >CTreeCtrl::CreateDragImage() are the culprits. The functions return a >pointer to an ImageList, but nowhere in the 4.2 docs does it say that I >need to delete the memory. Besides, this worked fine under 4.1. MFC 4.1 had a bug because it returned a temporary object when you called CListCtrl::CreateDragImage(). It turns out that you can (and just might) hold that object for longer than it takes to process the current message, and MFC might delete the temporary object in that time. MFC 4.2 fixes that problem by returning a permanent object. You're right: you do need to delete the returned object when you're done with it by yourself. The documentation doesn't say that, and that's a doc bug. .B ekiM http://www.nwlink.com/~mikeblas/ These words are my own. I do not speak on behalf of Microsoft. -----From: Gonzalo IsazaA bug in version 4.1 has been fixed. In VC++ 4.1 the image list was created as a temporary object. The problem was, the object was destroyed during idle time. A problematic situation could be the following : if a user implemented dragging without using the mouse buttons (just by moving the mouse), it was possible for OnIdle to execute at the same time the object was being dragged, destroying the CImageList object. The bug was fixed in 4.2 and it is necessary now to call delete for those image lists. Gonzalo. I speak for myself. I do not speak for Microsoft.
| Вернуться в корень Архива |