mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 19:43:23 +08:00
ccmake: Fix crash when deleting all cache entries
Prevents crash when deleting all cache entries. Additionally, if advanced entries are hidden, no longer show the first advanced entry when deleting all visible entries. Fixes: #23499
This commit is contained in:
@@ -93,13 +93,13 @@ void cmCursesMainForm::InitializeUI()
|
|||||||
|
|
||||||
int entrywidth = this->InitialWidth - 35;
|
int entrywidth = this->InitialWidth - 35;
|
||||||
|
|
||||||
if (count == 0) {
|
// Add a label to display when cache is empty
|
||||||
// If cache is empty, display a label saying so and a
|
|
||||||
// dummy entry widget (does not respond to input)
|
// dummy entry widget (does not respond to input)
|
||||||
cmCursesCacheEntryComposite comp("EMPTY CACHE", 30, 30);
|
cmCursesCacheEntryComposite comp("EMPTY CACHE", 30, 30);
|
||||||
comp.Entry = cm::make_unique<cmCursesDummyWidget>(1, 1, 1, 1);
|
comp.Entry = cm::make_unique<cmCursesDummyWidget>(1, 1, 1, 1);
|
||||||
newEntries.emplace_back(std::move(comp));
|
newEntries.emplace_back(std::move(comp));
|
||||||
} else {
|
|
||||||
|
if (count > 0) {
|
||||||
// Create the composites.
|
// Create the composites.
|
||||||
|
|
||||||
// First add entries which are new
|
// First add entries which are new
|
||||||
@@ -190,7 +190,8 @@ void cmCursesMainForm::RePost()
|
|||||||
this->Fields.push_back(entry.Entry->Field);
|
this->Fields.push_back(entry.Entry->Field);
|
||||||
}
|
}
|
||||||
// if no cache entries there should still be one dummy field
|
// if no cache entries there should still be one dummy field
|
||||||
if (this->Fields.empty()) {
|
this->IsEmpty = this->Fields.empty();
|
||||||
|
if (this->IsEmpty) {
|
||||||
const auto& front = this->Entries.front();
|
const auto& front = this->Entries.front();
|
||||||
this->Fields.push_back(front.Label->Field);
|
this->Fields.push_back(front.Label->Field);
|
||||||
this->Fields.push_back(front.IsNewLabel->Field);
|
this->Fields.push_back(front.IsNewLabel->Field);
|
||||||
@@ -869,7 +870,7 @@ void cmCursesMainForm::HandleInput()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// delete cache entry
|
// delete cache entry
|
||||||
else if (key == 'd' && this->NumberOfVisibleEntries) {
|
else if (key == 'd' && this->NumberOfVisibleEntries && !this->IsEmpty) {
|
||||||
this->OkToGenerate = false;
|
this->OkToGenerate = false;
|
||||||
FIELD* cur = current_field(this->Form);
|
FIELD* cur = current_field(this->Form);
|
||||||
size_t findex = field_index(cur);
|
size_t findex = field_index(cur);
|
||||||
|
@@ -161,6 +161,7 @@ protected:
|
|||||||
bool OkToGenerate = false;
|
bool OkToGenerate = false;
|
||||||
// Number of pages displayed
|
// Number of pages displayed
|
||||||
int NumberOfPages = 0;
|
int NumberOfPages = 0;
|
||||||
|
bool IsEmpty = false;
|
||||||
|
|
||||||
int InitialWidth;
|
int InitialWidth;
|
||||||
std::unique_ptr<cmake> CMakeInstance;
|
std::unique_ptr<cmake> CMakeInstance;
|
||||||
|
Reference in New Issue
Block a user