ENH: fix it for working with an empty cache
This commit is contained in:
parent
22f12322bb
commit
354abb72d9
|
@ -31,6 +31,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(const char* key,
|
||||||
this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
|
this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
|
||||||
this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
|
this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
|
||||||
this->Entry = 0;
|
this->Entry = 0;
|
||||||
|
this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
|
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
|
||||||
|
|
|
@ -218,7 +218,6 @@ void cmCursesMainForm::RePost()
|
||||||
this->Form = 0;
|
this->Form = 0;
|
||||||
}
|
}
|
||||||
delete[] this->Fields;
|
delete[] this->Fields;
|
||||||
|
|
||||||
if (this->AdvancedMode)
|
if (this->AdvancedMode)
|
||||||
{
|
{
|
||||||
this->NumberOfVisibleEntries = this->Entries->size();
|
this->NumberOfVisibleEntries = this->Entries->size();
|
||||||
|
@ -239,7 +238,11 @@ void cmCursesMainForm::RePost()
|
||||||
this->NumberOfVisibleEntries++;
|
this->NumberOfVisibleEntries++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// there is always one even if it is the dummy one
|
||||||
|
if(this->NumberOfVisibleEntries == 0)
|
||||||
|
{
|
||||||
|
this->NumberOfVisibleEntries = 1;
|
||||||
|
}
|
||||||
// Assign the fields: 3 for each entry: label, new entry marker
|
// Assign the fields: 3 for each entry: label, new entry marker
|
||||||
// ('*' or ' ') and entry widget
|
// ('*' or ' ') and entry widget
|
||||||
this->Fields = new FIELD*[3*this->NumberOfVisibleEntries+1];
|
this->Fields = new FIELD*[3*this->NumberOfVisibleEntries+1];
|
||||||
|
@ -265,7 +268,15 @@ void cmCursesMainForm::RePost()
|
||||||
this->Fields[3*j+2] = (*it)->Entry->Field;
|
this->Fields[3*j+2] = (*it)->Entry->Field;
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
// if no cache entries there should still be one dummy field
|
||||||
|
if(j == 0)
|
||||||
|
{
|
||||||
|
it = this->Entries->begin();
|
||||||
|
this->Fields[0] = (*it)->Label->Field;
|
||||||
|
this->Fields[1] = (*it)->IsNewLabel->Field;
|
||||||
|
this->Fields[2] = (*it)->Entry->Field;
|
||||||
|
this->NumberOfVisibleEntries = 1;
|
||||||
|
}
|
||||||
// Has to be null terminated.
|
// Has to be null terminated.
|
||||||
this->Fields[3*this->NumberOfVisibleEntries] = 0;
|
this->Fields[3*this->NumberOfVisibleEntries] = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue