trying to fix memory leak in wxListCtrl (attributes not deleted)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5889 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -331,6 +331,9 @@ protected:
|
|||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
|
// free memory taken by all attributes
|
||||||
|
void FreeAllAttrs();
|
||||||
|
|
||||||
wxTextCtrl* m_textCtrl; // The control used for editing a label
|
wxTextCtrl* m_textCtrl; // The control used for editing a label
|
||||||
wxImageList * m_imageListNormal; // The image list for normal icons
|
wxImageList * m_imageListNormal; // The image list for normal icons
|
||||||
wxImageList * m_imageListSmall; // The image list for small icons
|
wxImageList * m_imageListSmall; // The image list for small icons
|
||||||
|
@@ -239,7 +239,7 @@ void wxListCtrl::UpdateStyle()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxListCtrl::~wxListCtrl()
|
void wxListCtrl::FreeAllAttrs()
|
||||||
{
|
{
|
||||||
if ( m_hasAnyAttr )
|
if ( m_hasAnyAttr )
|
||||||
{
|
{
|
||||||
@@ -247,8 +247,15 @@ wxListCtrl::~wxListCtrl()
|
|||||||
{
|
{
|
||||||
delete (wxListItemAttr *)node->Data();
|
delete (wxListItemAttr *)node->Data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_attrs.Destroy();
|
||||||
|
|
||||||
|
m_hasAnyAttr = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxListCtrl::~wxListCtrl()
|
||||||
|
{
|
||||||
if ( m_textCtrl )
|
if ( m_textCtrl )
|
||||||
{
|
{
|
||||||
m_textCtrl->UnsubclassWin();
|
m_textCtrl->UnsubclassWin();
|
||||||
@@ -1295,18 +1302,10 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LVN_DELETEALLITEMS:
|
case LVN_DELETEALLITEMS:
|
||||||
// What's the sense of generating a wxWin event for this when
|
|
||||||
// it's absolutely not portable?
|
|
||||||
// This is perfectly portable, RR
|
|
||||||
#if 1
|
|
||||||
eventType = wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS;
|
eventType = wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS;
|
||||||
event.m_itemIndex = -1;
|
event.m_itemIndex = -1;
|
||||||
#endif // 1
|
|
||||||
|
|
||||||
// return TRUE to suppress all additional LVN_DELETEITEM
|
FreeAllAttrs();
|
||||||
// notifications - this makes deleting all items from a list ctrl
|
|
||||||
// much faster
|
|
||||||
*result = TRUE;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1579,19 +1578,19 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
if ( !GetEventHandler()->ProcessEvent(event) )
|
if ( !GetEventHandler()->ProcessEvent(event) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (eventType == wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS)
|
|
||||||
{
|
|
||||||
// No postprocessing, because we want *return to
|
|
||||||
// be TRUE so that no further DeleteItem events
|
|
||||||
// are sent, RR.
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// post processing
|
// post processing
|
||||||
// ---------------
|
// ---------------
|
||||||
|
|
||||||
switch ( (int)nmhdr->code )
|
switch ( (int)nmhdr->code )
|
||||||
{
|
{
|
||||||
|
case LVN_DELETEALLITEMS:
|
||||||
|
// always return TRUE to suppress all additional LVN_DELETEITEM
|
||||||
|
// notifications - this makes deleting all items from a list ctrl
|
||||||
|
// much faster
|
||||||
|
*result = TRUE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
case LVN_GETDISPINFO:
|
case LVN_GETDISPINFO:
|
||||||
{
|
{
|
||||||
LV_DISPINFO *info = (LV_DISPINFO *)lParam;
|
LV_DISPINFO *info = (LV_DISPINFO *)lParam;
|
||||||
@@ -1611,8 +1610,6 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
*result = event.IsAllowed();
|
*result = event.IsAllowed();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*result = !event.IsAllowed();
|
*result = !event.IsAllowed();
|
||||||
|
Reference in New Issue
Block a user