diff options
author | Brad King <brad.king@kitware.com> | 2019-01-30 13:10:19 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-01-30 13:10:27 (GMT) |
commit | c30f9b1cdefc2fa26d89bc692001a4f1050f6038 (patch) | |
tree | 2c862b3be88b4b600f6ac515d4c76fb039c8df2f /Source/QtDialog | |
parent | bcec7d0778eb87ea58d720d9e20710dc2cdfdab6 (diff) | |
parent | 8c92db829b41243790c7dcc5300227f591a727a8 (diff) | |
download | CMake-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/QtDialog')
-rw-r--r-- | Source/QtDialog/QCMake.cxx | 50 | ||||
-rw-r--r-- | Source/QtDialog/QCMake.h | 12 |
2 files changed, 33 insertions, 29 deletions
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 2eecce6..065d610 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -23,16 +23,26 @@ QCMake::QCMake(QObject* p) cmSystemTools::DisableRunCommandOutput(); cmSystemTools::SetRunCommandHideConsole(true); - cmSystemTools::SetMessageCallback(QCMake::messageCallback, this); - cmSystemTools::SetStdoutCallback(QCMake::stdoutCallback, this); - cmSystemTools::SetStderrCallback(QCMake::stderrCallback, this); + + cmSystemTools::SetMessageCallback( + [this](const char* msg, const char* title) { + this->messageCallback(msg, title); + }); + cmSystemTools::SetStdoutCallback( + [this](const char* msg, size_t len) { this->stdoutCallback(msg, len); }); + cmSystemTools::SetStderrCallback( + [this](const char* msg, size_t len) { this->stderrCallback(msg, len); }); this->CMakeInstance = new cmake(cmake::RoleProject, cmState::Project); this->CMakeInstance->SetCMakeEditCommand( cmSystemTools::GetCMakeGUICommand()); - this->CMakeInstance->SetProgressCallback(QCMake::progressCallback, this); + this->CMakeInstance->SetProgressCallback( + [this](const char* msg, float percent) { + this->progressCallback(msg, percent); + }); - cmSystemTools::SetInterruptCallback(QCMake::interruptCallback, this); + cmSystemTools::SetInterruptCallback( + [this] { return this->interruptCallback(); }); std::vector<cmake::GeneratorInfo> generators; this->CMakeInstance->GetRegisteredGenerators( @@ -330,46 +340,40 @@ void QCMake::interrupt() this->InterruptFlag.ref(); } -bool QCMake::interruptCallback(void* cd) +bool QCMake::interruptCallback() { - QCMake* self = reinterpret_cast<QCMake*>(cd); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - return self->InterruptFlag; + return this->InterruptFlag; #else - return self->InterruptFlag.load(); + return this->InterruptFlag.load(); #endif } -void QCMake::progressCallback(const char* msg, float percent, void* cd) +void QCMake::progressCallback(const char* msg, float percent) { - QCMake* self = reinterpret_cast<QCMake*>(cd); if (percent >= 0) { - emit self->progressChanged(QString::fromLocal8Bit(msg), percent); + emit this->progressChanged(QString::fromLocal8Bit(msg), percent); } else { - emit self->outputMessage(QString::fromLocal8Bit(msg)); + emit this->outputMessage(QString::fromLocal8Bit(msg)); } QCoreApplication::processEvents(); } -void QCMake::messageCallback(const char* msg, const char* /*title*/, - bool& /*stop*/, void* cd) +void QCMake::messageCallback(const char* msg, const char* /*title*/) { - QCMake* self = reinterpret_cast<QCMake*>(cd); - emit self->errorMessage(QString::fromLocal8Bit(msg)); + emit this->errorMessage(QString::fromLocal8Bit(msg)); QCoreApplication::processEvents(); } -void QCMake::stdoutCallback(const char* msg, size_t len, void* cd) +void QCMake::stdoutCallback(const char* msg, size_t len) { - QCMake* self = reinterpret_cast<QCMake*>(cd); - emit self->outputMessage(QString::fromLocal8Bit(msg, int(len))); + emit this->outputMessage(QString::fromLocal8Bit(msg, int(len))); QCoreApplication::processEvents(); } -void QCMake::stderrCallback(const char* msg, size_t len, void* cd) +void QCMake::stderrCallback(const char* msg, size_t len) { - QCMake* self = reinterpret_cast<QCMake*>(cd); - emit self->outputMessage(QString::fromLocal8Bit(msg, int(len))); + emit this->outputMessage(QString::fromLocal8Bit(msg, int(len))); QCoreApplication::processEvents(); } diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index c84da58..4f22505 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -167,12 +167,12 @@ signals: protected: cmake* CMakeInstance; - static bool interruptCallback(void*); - static void progressCallback(const char* msg, float percent, void* cd); - static void messageCallback(const char* msg, const char* title, bool&, - void* cd); - static void stdoutCallback(const char* msg, size_t len, void* cd); - static void stderrCallback(const char* msg, size_t len, void* cd); + bool interruptCallback(); + void progressCallback(const char* msg, float percent); + void messageCallback(const char* msg, const char* title); + void stdoutCallback(const char* msg, size_t len); + void stderrCallback(const char* msg, size_t len); + bool WarnUninitializedMode; bool WarnUnusedMode; bool WarnUnusedAllMode; |