diff options
author | Martin Duffy <martin.duffy@kitware.com> | 2022-05-16 21:36:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-05-18 12:04:10 (GMT) |
commit | 432a8ab7391c0cb3785561097283bba78ca985e5 (patch) | |
tree | 509e43a65613c09f9453b9ac86f1f7c6cc488016 /Source/CursesDialog | |
parent | 29d23ec2cf8c24d408a8f9f227c5b52152e2f8d0 (diff) | |
download | CMake-432a8ab7391c0cb3785561097283bba78ca985e5.zip CMake-432a8ab7391c0cb3785561097283bba78ca985e5.tar.gz CMake-432a8ab7391c0cb3785561097283bba78ca985e5.tar.bz2 |
ccmake: Fix infinite loop during invalid search
Fix issue introduced in commit 2defe9ff95 (ccmake: Fix crash when
deleting all cache entries, 2022-05-12).
Leaving the Empty Cache widget always on the Entry list had unforeseen
consequences, including that it caused an infinite loop when searching
for a string that did not match any variables.
Diffstat (limited to 'Source/CursesDialog')
-rw-r--r-- | Source/CursesDialog/cmCursesMainForm.cxx | 14 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesMainForm.h | 1 |
2 files changed, 8 insertions, 7 deletions
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 3e254e0..8381e86 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -95,9 +95,10 @@ void cmCursesMainForm::InitializeUI() // Add a label to display when cache is empty // dummy entry widget (does not respond to input) - cmCursesCacheEntryComposite comp("EMPTY CACHE", 30, 30); - comp.Entry = cm::make_unique<cmCursesDummyWidget>(1, 1, 1, 1); - newEntries.emplace_back(std::move(comp)); + this->EmptyCacheEntry = + cm::make_unique<cmCursesCacheEntryComposite>("EMPTY CACHE", 30, 30); + this->EmptyCacheEntry->Entry = + cm::make_unique<cmCursesDummyWidget>(1, 1, 1, 1); if (count > 0) { // Create the composites. @@ -192,10 +193,9 @@ void cmCursesMainForm::RePost() // if no cache entries there should still be one dummy field this->IsEmpty = this->Fields.empty(); if (this->IsEmpty) { - const auto& front = this->Entries.front(); - this->Fields.push_back(front.Label->Field); - this->Fields.push_back(front.IsNewLabel->Field); - this->Fields.push_back(front.Entry->Field); + this->Fields.push_back(this->EmptyCacheEntry->Label->Field); + this->Fields.push_back(this->EmptyCacheEntry->IsNewLabel->Field); + this->Fields.push_back(this->EmptyCacheEntry->Entry->Field); this->NumberOfVisibleEntries = 1; } // Has to be null terminated. diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index fb44a45..112b7e8 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -162,6 +162,7 @@ protected: // Number of pages displayed int NumberOfPages = 0; bool IsEmpty = false; + std::unique_ptr<cmCursesCacheEntryComposite> EmptyCacheEntry; int InitialWidth; std::unique_ptr<cmake> CMakeInstance; |