From 07763c990ed83f6879e73431de6f7ec1825f5d56 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 29 Jan 2005 21:26:25 +0000 Subject: [PATCH] do reset m_count to 0 after deleting all the items in the control (was broken by last commit) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31645 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/listctrl.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 25c10a2929..90c122a4cc 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -480,8 +480,6 @@ void wxListCtrl::FreeAllInternalData() m_ignoreChangeMessages = false; m_AnyInternalData = false; - - m_count = 0; } } @@ -497,9 +495,12 @@ wxListCtrl::~wxListCtrl() m_textCtrl = NULL; } - if (m_ownsImageListNormal) delete m_imageListNormal; - if (m_ownsImageListSmall) delete m_imageListSmall; - if (m_ownsImageListState) delete m_imageListState; + if (m_ownsImageListNormal) + delete m_imageListNormal; + if (m_ownsImageListSmall) + delete m_imageListSmall; + if (m_ownsImageListState) + delete m_imageListState; } // ---------------------------------------------------------------------------- @@ -1925,10 +1926,12 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) break; case LVN_DELETEITEM: - if (m_count == 0) - // this should be prevented by the post-processing code below, - // but "just in case" + if ( m_count == 0 ) + { + // this should be prevented by the post-processing code + // below, but "just in case" return false; + } eventType = wxEVT_COMMAND_LIST_DELETE_ITEM; event.m_itemIndex = iItem; @@ -2194,6 +2197,10 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) // also, we may free all user data now (couldn't do it before as // the user should have access to it in OnDeleteAllItems() handler) FreeAllInternalData(); + + // the control is empty now, synchronize the cached number of items + // with the real one + m_count = 0; return true; case LVN_ENDLABELEDITA: -- 2.45.2