ccmake: Free main form before destroying cache entry fields

InitializeUI() replaced the cache entry widgets and the "EMPTY CACHE"
placeholder, and RemoveEntry() erased an entry, while the form still
referenced their fields.  free_field() fails on connected fields, so
every reconfigure and every deleted entry leaked fields.  Free the form
first; RePost() and Render() create a new one afterwards.
This commit is contained in:
Christoph Grüninger committed 2026-10-28 23:36:10 +01:00
1 parent 1835cffe66
commit 5532f2c69d
1 file changed
+13
+13
View File
@@ -74,6 +74,13 @@ void cmCursesMainForm::InitializeUI()
// Hide the cursor by default
curs_set(0);
// Free the form before destroying the fields it references
if (this->Form) {
unpost_form(this->Form);
free_form(this->Form);
this->Form = nullptr;
}
// Create a vector of cmCursesCacheEntryComposite's
// which contain labels, entries and new entry markers
std::vector<cmCursesCacheEntryComposite> newEntries;
@@ -620,6 +627,12 @@ void cmCursesMainForm::RemoveEntry(char const* value)
if (removeIt != this->Entries.end()) {
this->CMakeInstance->UnwatchUnusedCli(value);
// Free the form before destroying the fields it references
if (this->Form) {
unpost_form(this->Form);
free_form(this->Form);
this->Form = nullptr;
}
this->Entries.erase(removeIt);
}
}