From b5746484e4c396489b707e0f8b4d1f539e62a965 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 24 Apr 2001 14:19:13 -0400 Subject: BUG: fix duplicate property items --- Source/MFCDialog/CMakeSetupDialog.cpp | 4 ++-- Source/MFCDialog/PropertyList.cpp | 23 ++++++++++++++++++++--- Source/MFCDialog/PropertyList.h | 6 +++--- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp index add242b..e06aaa3 100644 --- a/Source/MFCDialog/CMakeSetupDialog.cpp +++ b/Source/MFCDialog/CMakeSetupDialog.cpp @@ -453,8 +453,8 @@ void CMakeSetupDialog::FillCacheManagerFromCacheEditor() { cmCacheManager::CacheEntryMap cache = cmCacheManager::GetInstance()->GetCacheMap(); - std::list items = m_CacheEntriesList.GetItems(); - for(std::list::iterator i = items.begin(); + std::set items = m_CacheEntriesList.GetItems(); + for(std::set::iterator i = items.begin(); i != items.end(); ++i) { CPropertyItem* item = *i; diff --git a/Source/MFCDialog/PropertyList.cpp b/Source/MFCDialog/PropertyList.cpp index a4b2aea..b798e10 100644 --- a/Source/MFCDialog/PropertyList.cpp +++ b/Source/MFCDialog/PropertyList.cpp @@ -20,7 +20,7 @@ CPropertyList::CPropertyList() CPropertyList::~CPropertyList() { - for(std::list::iterator i = m_PropertyItems.begin(); + for(std::set::iterator i = m_PropertyItems.begin(); i != m_PropertyItems.end(); ++i) { delete *i; @@ -118,7 +118,7 @@ int CPropertyList::AddPropItem(CPropertyItem* pItem) { int nIndex = AddString(_T("")); SetItemDataPtr(nIndex,pItem); - m_PropertyItems.push_back(pItem); + m_PropertyItems.insert(pItem); return nIndex; } @@ -143,8 +143,25 @@ int CPropertyList::AddProperty(const char* name, return i; } } + // if it is not in the displayed list, then + // check for it in the m_PropertyItems list as + // a removed item + for(std::set::iterator + p = m_PropertyItems.begin(); + p != m_PropertyItems.end(); ++p) + { + if((*p)->m_propName == name) + { + pItem = *p; + pItem->m_Removed = false; + } + } // if it is not found, then create a new one - pItem = new CPropertyItem(name, value, type, comboItems); + if(!pItem) + { + pItem = new CPropertyItem(name, value, type, comboItems); + } + return this->AddPropItem(pItem); } diff --git a/Source/MFCDialog/PropertyList.h b/Source/MFCDialog/PropertyList.h index c6d65ed..a5a8f21 100644 --- a/Source/MFCDialog/PropertyList.h +++ b/Source/MFCDialog/PropertyList.h @@ -19,7 +19,7 @@ #define IDC_PROPBTNCTRL 714 #define IDC_PROPCHECKBOXCTRL 715 -#include +#include "../cmStandardIncludes.h" ///////////////////////////////////////////////////////////////////////////// //CPropertyList Items @@ -63,7 +63,7 @@ public: const char* value, int type, const char* comboItems); - std::list GetItems() + std::set GetItems() { return m_PropertyItems; } @@ -130,7 +130,7 @@ protected: BOOL m_bDivIsSet; HCURSOR m_hCursorArrow; HCURSOR m_hCursorSize; - std::list m_PropertyItems; + std::set m_PropertyItems; }; ///////////////////////////////////////////////////////////////////////////// -- cgit v0.12