summaryrefslogtreecommitdiffstats
path: root/Source/CursesDialog
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-05-13 12:45:43 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-05-13 12:45:51 (GMT)
commit57559d2848518764a18f60ddf8546dcdd80ca5ce (patch)
tree855ea4f9479a885ac30f53ca59187843d615ec89 /Source/CursesDialog
parent4d8e4caefff9b378576d284a801baf8995137519 (diff)
parent2defe9ff95016fd72e9a16b4a8fa8b8d0ec5a45f (diff)
downloadCMake-57559d2848518764a18f60ddf8546dcdd80ca5ce.zip
CMake-57559d2848518764a18f60ddf8546dcdd80ca5ce.tar.gz
CMake-57559d2848518764a18f60ddf8546dcdd80ca5ce.tar.bz2
Merge topic 'ccmake-delete-cache'
2defe9ff95 ccmake: Fix crash when deleting all cache entries e1c85e29f4 ccmake: Move Initialization of Fields Inline Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !7257
Diffstat (limited to 'Source/CursesDialog')
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx25
-rw-r--r--Source/CursesDialog/cmCursesMainForm.h13
2 files changed, 17 insertions, 21 deletions
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 11b3b35..3e254e0 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -35,11 +35,6 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> args,
: Args(std::move(args))
, InitialWidth(initWidth)
{
- this->HasNonStatusOutputs = false;
- this->NumberOfPages = 0;
- this->AdvancedMode = false;
- this->NumberOfVisibleEntries = 0;
- this->OkToGenerate = false;
this->HelpMessage.emplace_back(
"Welcome to ccmake, curses based user interface for CMake.");
this->HelpMessage.emplace_back();
@@ -54,7 +49,6 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> args,
cmStrCat(cmSystemTools::GetProgramPath(this->Args[0]), "/cmake");
this->Args[0] = whereCMake;
this->CMakeInstance->SetArgs(this->Args);
- this->SearchMode = false;
}
cmCursesMainForm::~cmCursesMainForm()
@@ -99,13 +93,13 @@ void cmCursesMainForm::InitializeUI()
int entrywidth = this->InitialWidth - 35;
- if (count == 0) {
- // If cache is empty, display a label saying so and a
- // 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));
- } else {
+ // 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));
+
+ if (count > 0) {
// Create the composites.
// First add entries which are new
@@ -196,7 +190,8 @@ void cmCursesMainForm::RePost()
this->Fields.push_back(entry.Entry->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();
this->Fields.push_back(front.Label->Field);
this->Fields.push_back(front.IsNewLabel->Field);
@@ -875,7 +870,7 @@ void cmCursesMainForm::HandleInput()
}
}
// delete cache entry
- else if (key == 'd' && this->NumberOfVisibleEntries) {
+ else if (key == 'd' && this->NumberOfVisibleEntries && !this->IsEmpty) {
this->OkToGenerate = false;
FIELD* cur = current_field(this->Form);
size_t findex = field_index(cur);
diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h
index c6db66f..fb44a45 100644
--- a/Source/CursesDialog/cmCursesMainForm.h
+++ b/Source/CursesDialog/cmCursesMainForm.h
@@ -138,7 +138,7 @@ protected:
// Output produced by the last pass
std::vector<std::string> Outputs;
// Did the last pass produced outputs of interest (errors, warnings, ...)
- bool HasNonStatusOutputs;
+ bool HasNonStatusOutputs = false;
// Last progress bar
std::string LastProgress;
@@ -155,17 +155,18 @@ protected:
// Fields displayed. Includes labels, new entry markers, entries
std::vector<FIELD*> Fields;
// Number of entries shown (depends on mode -normal or advanced-)
- size_t NumberOfVisibleEntries;
- bool AdvancedMode;
+ size_t NumberOfVisibleEntries = 0;
+ bool AdvancedMode = false;
// Did the iteration converge (no new entries) ?
- bool OkToGenerate;
+ bool OkToGenerate = false;
// Number of pages displayed
- int NumberOfPages;
+ int NumberOfPages = 0;
+ bool IsEmpty = false;
int InitialWidth;
std::unique_ptr<cmake> CMakeInstance;
std::string SearchString;
std::string OldSearchString;
- bool SearchMode;
+ bool SearchMode = false;
};