summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2004-02-23 03:06:33 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2004-02-23 03:06:33 (GMT)
commit183273bea2b093043abb06845dffa7b902b6d273 (patch)
tree95d9bfdeae296d9e2531713be3316d8a14d2fcd1
parent2ccce878a3af74d7a7328e42bd76825366a82112 (diff)
downloadCMake-183273bea2b093043abb06845dffa7b902b6d273.zip
CMake-183273bea2b093043abb06845dffa7b902b6d273.tar.gz
CMake-183273bea2b093043abb06845dffa7b902b6d273.tar.bz2
BUG: Prevent crash when deleting the last cache item
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx59
1 files changed, 34 insertions, 25 deletions
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 7bfbef4..2a8b299 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -241,6 +241,11 @@ void cmCursesMainForm::RePost()
// Assign the fields: 3 for each entry: label, new entry marker
// ('*' or ' ') and entry widget
m_Fields = new FIELD*[3*m_NumberOfVisibleEntries+1];
+ int cc;
+ for ( cc = 0; cc < 3 * m_NumberOfVisibleEntries+1; cc ++ )
+ {
+ m_Fields[cc] = 0;
+ }
// Assign fields
int j=0;
@@ -1096,37 +1101,41 @@ void cmCursesMainForm::HandleInput()
// each entry consists of fields: label, isnew, value
// therefore, the label field for the is findex-2
// (findex always corresponds to the value field)
- cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>(field_userptr(
- m_Fields[findex-2]));
- this->m_CMakeInstance->GetCacheManager()->RemoveCacheEntry(lbl->GetValue());
-
- std::string nextVal;
- if (nextCur)
+ cmCursesWidget* lbl
+ = reinterpret_cast<cmCursesWidget*>(
+ field_userptr(m_Fields[findex-2]));
+ if ( lbl )
{
- nextVal = (reinterpret_cast<cmCursesWidget*>(field_userptr(nextCur))->GetValue());
- }
+ this->m_CMakeInstance->GetCacheManager()->RemoveCacheEntry(lbl->GetValue());
- getmaxyx(stdscr, y, x);
- this->RemoveEntry(lbl->GetValue());
- this->RePost();
- this->Render(1, 1, x, y);
-
- if (nextCur)
- {
- // make the next or prev. current field after deletion
- nextCur = 0;
- std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = m_Entries->begin(); it != m_Entries->end(); ++it)
+ std::string nextVal;
+ if (nextCur)
{
- if (nextVal == (*it)->m_Key)
- {
- nextCur = (*it)->m_Entry->m_Field;
- }
+ nextVal = (reinterpret_cast<cmCursesWidget*>(field_userptr(nextCur))->GetValue());
}
-
+
+ getmaxyx(stdscr, y, x);
+ this->RemoveEntry(lbl->GetValue());
+ this->RePost();
+ this->Render(1, 1, x, y);
+
if (nextCur)
{
- set_current_field(m_Form, nextCur);
+ // make the next or prev. current field after deletion
+ nextCur = 0;
+ std::vector<cmCursesCacheEntryComposite*>::iterator it;
+ for (it = m_Entries->begin(); it != m_Entries->end(); ++it)
+ {
+ if (nextVal == (*it)->m_Key)
+ {
+ nextCur = (*it)->m_Entry->m_Field;
+ }
+ }
+
+ if (nextCur)
+ {
+ set_current_field(m_Form, nextCur);
+ }
}
}
}