BUG: fix duplicate property items

This commit is contained in:
Bill Hoffman 2001-04-24 14:19:13 -04:00
parent 37468fad3a
commit b5746484e4
3 changed files with 25 additions and 8 deletions

View File

@ -453,8 +453,8 @@ void CMakeSetupDialog::FillCacheManagerFromCacheEditor()
{ {
cmCacheManager::CacheEntryMap cache = cmCacheManager::CacheEntryMap cache =
cmCacheManager::GetInstance()->GetCacheMap(); cmCacheManager::GetInstance()->GetCacheMap();
std::list<CPropertyItem*> items = m_CacheEntriesList.GetItems(); std::set<CPropertyItem*> items = m_CacheEntriesList.GetItems();
for(std::list<CPropertyItem*>::iterator i = items.begin(); for(std::set<CPropertyItem*>::iterator i = items.begin();
i != items.end(); ++i) i != items.end(); ++i)
{ {
CPropertyItem* item = *i; CPropertyItem* item = *i;

View File

@ -20,7 +20,7 @@ CPropertyList::CPropertyList()
CPropertyList::~CPropertyList() CPropertyList::~CPropertyList()
{ {
for(std::list<CPropertyItem*>::iterator i = m_PropertyItems.begin(); for(std::set<CPropertyItem*>::iterator i = m_PropertyItems.begin();
i != m_PropertyItems.end(); ++i) i != m_PropertyItems.end(); ++i)
{ {
delete *i; delete *i;
@ -118,7 +118,7 @@ int CPropertyList::AddPropItem(CPropertyItem* pItem)
{ {
int nIndex = AddString(_T("")); int nIndex = AddString(_T(""));
SetItemDataPtr(nIndex,pItem); SetItemDataPtr(nIndex,pItem);
m_PropertyItems.push_back(pItem); m_PropertyItems.insert(pItem);
return nIndex; return nIndex;
} }
@ -143,8 +143,25 @@ int CPropertyList::AddProperty(const char* name,
return i; 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<CPropertyItem*>::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 // 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); return this->AddPropItem(pItem);
} }

View File

@ -19,7 +19,7 @@
#define IDC_PROPBTNCTRL 714 #define IDC_PROPBTNCTRL 714
#define IDC_PROPCHECKBOXCTRL 715 #define IDC_PROPCHECKBOXCTRL 715
#include <list> #include "../cmStandardIncludes.h"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
//CPropertyList Items //CPropertyList Items
@ -63,7 +63,7 @@ public:
const char* value, const char* value,
int type, int type,
const char* comboItems); const char* comboItems);
std::list<CPropertyItem*> GetItems() std::set<CPropertyItem*> GetItems()
{ {
return m_PropertyItems; return m_PropertyItems;
} }
@ -130,7 +130,7 @@ protected:
BOOL m_bDivIsSet; BOOL m_bDivIsSet;
HCURSOR m_hCursorArrow; HCURSOR m_hCursorArrow;
HCURSOR m_hCursorSize; HCURSOR m_hCursorSize;
std::list<CPropertyItem*> m_PropertyItems; std::set<CPropertyItem*> m_PropertyItems;
}; };
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////