summaryrefslogtreecommitdiffstats
path: root/Source/CursesDialog
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-01-30 13:10:19 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-01-30 13:10:27 (GMT)
commitc30f9b1cdefc2fa26d89bc692001a4f1050f6038 (patch)
tree2c862b3be88b4b600f6ac515d4c76fb039c8df2f /Source/CursesDialog
parentbcec7d0778eb87ea58d720d9e20710dc2cdfdab6 (diff)
parent8c92db829b41243790c7dcc5300227f591a727a8 (diff)
downloadCMake-c30f9b1cdefc2fa26d89bc692001a4f1050f6038.zip
CMake-c30f9b1cdefc2fa26d89bc692001a4f1050f6038.tar.gz
CMake-c30f9b1cdefc2fa26d89bc692001a4f1050f6038.tar.bz2
Merge topic 'functional-callbacks'
8c92db829b MessageCallback: Remove unused bool& argument bcee24aecc Use `std::function` for callbacks Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: vvs31415 <vstakhovsky@fastmail.com> Acked-by: Daniel Pfeifer <daniel@pfeifer-mail.de> Merge-request: !2872
Diffstat (limited to 'Source/CursesDialog')
-rw-r--r--Source/CursesDialog/ccmake.cxx12
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx22
-rw-r--r--Source/CursesDialog/cmCursesMainForm.h3
3 files changed, 14 insertions, 23 deletions
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index dbf4a28..f2982a6 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -65,13 +65,6 @@ void onsig(int /*unused*/)
}
}
-void CMakeMessageHandler(const char* message, const char* title,
- bool& /*unused*/, void* clientData)
-{
- cmCursesForm* self = static_cast<cmCursesForm*>(clientData);
- self->AddError(message, title);
-}
-
int main(int argc, char const* const* argv)
{
cmsys::Encoding::CommandLineArguments encoding_args =
@@ -156,7 +149,10 @@ int main(int argc, char const* const* argv)
return 1;
}
- cmSystemTools::SetMessageCallback(CMakeMessageHandler, myform);
+ cmSystemTools::SetMessageCallback(
+ [myform](const char* message, const char* title) {
+ myform->AddError(message, title);
+ });
cmCursesForm::CurrentForm = myform;
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 188ad69..8ca7802 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -506,12 +506,8 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
pos_form_cursor(this->Form);
}
-void cmCursesMainForm::UpdateProgress(const char* msg, float prog, void* vp)
+void cmCursesMainForm::UpdateProgress(const char* msg, float prog)
{
- cmCursesMainForm* cm = static_cast<cmCursesMainForm*>(vp);
- if (!cm) {
- return;
- }
char tmp[1024];
const char* cmsg = tmp;
if (prog >= 0) {
@@ -519,8 +515,8 @@ void cmCursesMainForm::UpdateProgress(const char* msg, float prog, void* vp)
} else {
cmsg = msg;
}
- cm->UpdateStatusBar(cmsg);
- cm->PrintKeys(1);
+ this->UpdateStatusBar(cmsg);
+ this->PrintKeys(1);
curses_move(1, 1);
touchwin(stdscr);
refresh();
@@ -536,8 +532,8 @@ int cmCursesMainForm::Configure(int noconfigure)
this->PrintKeys(1);
touchwin(stdscr);
refresh();
- this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress,
- this);
+ this->CMakeInstance->SetProgressCallback(
+ [this](const char* msg, float prog) { this->UpdateProgress(msg, prog); });
// always save the current gui values to disk
this->FillCacheManagerFromUI();
@@ -560,7 +556,7 @@ int cmCursesMainForm::Configure(int noconfigure)
} else {
retVal = this->CMakeInstance->Configure();
}
- this->CMakeInstance->SetProgressCallback(nullptr, nullptr);
+ this->CMakeInstance->SetProgressCallback(nullptr);
keypad(stdscr, true); /* Use key symbols as KEY_DOWN */
@@ -606,8 +602,8 @@ int cmCursesMainForm::Generate()
this->PrintKeys(1);
touchwin(stdscr);
refresh();
- this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress,
- this);
+ this->CMakeInstance->SetProgressCallback(
+ [this](const char* msg, float prog) { this->UpdateProgress(msg, prog); });
// Get rid of previous errors
this->Errors = std::vector<std::string>();
@@ -615,7 +611,7 @@ int cmCursesMainForm::Generate()
// run the generate process
int retVal = this->CMakeInstance->Generate();
- this->CMakeInstance->SetProgressCallback(nullptr, nullptr);
+ this->CMakeInstance->SetProgressCallback(nullptr);
keypad(stdscr, true); /* Use key symbols as KEY_DOWN */
if (retVal != 0 || !this->Errors.empty()) {
diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h
index 824025b..88864bc 100644
--- a/Source/CursesDialog/cmCursesMainForm.h
+++ b/Source/CursesDialog/cmCursesMainForm.h
@@ -101,8 +101,7 @@ public:
/**
* Progress callback
*/
- static void UpdateProgressOld(const char* msg, float prog, void*);
- static void UpdateProgress(const char* msg, float prog, void*);
+ void UpdateProgress(const char* msg, float prog);
protected:
// Copy the cache values from the user interface to the actual