From c26a6fef8b7afb8e1a34c1b739517cb06a8c3d06 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Sat, 19 Mar 2016 21:07:15 +0000 Subject: [PATCH] refs #624 Use noexcept instead of Q_DECL_NOEXCEPT. --- src/blackmisc/range.h | 2 +- src/blackmisc/statusexception.cpp | 2 +- src/blackmisc/statusexception.h | 2 +- src/blackmisc/worker.cpp | 10 +++++----- src/blackmisc/worker.h | 14 +++++++------- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/blackmisc/range.h b/src/blackmisc/range.h index e505609ef..ed09052a2 100644 --- a/src/blackmisc/range.h +++ b/src/blackmisc/range.h @@ -45,7 +45,7 @@ namespace BlackMisc */ //! @{ template - constexpr typename std::add_const::type &as_const(T &v) Q_DECL_NOEXCEPT { return v; } + constexpr typename std::add_const::type &as_const(T &v) noexcept { return v; } template void as_const(const T &&) = delete; //! @} diff --git a/src/blackmisc/statusexception.cpp b/src/blackmisc/statusexception.cpp index a7c22d1f6..3736bb84a 100644 --- a/src/blackmisc/statusexception.cpp +++ b/src/blackmisc/statusexception.cpp @@ -21,7 +21,7 @@ namespace BlackMisc this->m_temp = other.m_temp; } - const char *CStatusException::what() const Q_DECL_NOEXCEPT + const char *CStatusException::what() const noexcept { QWriteLocker lock(&this->m_lock); if (m_temp.isNull()) { m_temp = m_payload.getMessage().toLocal8Bit(); } diff --git a/src/blackmisc/statusexception.h b/src/blackmisc/statusexception.h index 7dc770bb7..2d9756f68 100644 --- a/src/blackmisc/statusexception.h +++ b/src/blackmisc/statusexception.h @@ -35,7 +35,7 @@ namespace BlackMisc CStatusException &operator=(const CStatusException &) = delete; //! Return null-terminated message string. - virtual const char *what() const Q_DECL_NOEXCEPT override; + virtual const char *what() const noexcept override; //! Return the contained status message. const CStatusMessage &status() const { return m_payload; } diff --git a/src/blackmisc/worker.cpp b/src/blackmisc/worker.cpp index 2bf5575a8..2c2a33312 100644 --- a/src/blackmisc/worker.cpp +++ b/src/blackmisc/worker.cpp @@ -45,20 +45,20 @@ namespace BlackMisc QMetaObject::invokeMethod(this, "deleteLater"); } - void CWorkerBase::waitForFinished() Q_DECL_NOEXCEPT + void CWorkerBase::waitForFinished() noexcept { std::promise promise; then([ & ] { promise.set_value(); }); promise.get_future().wait(); } - void CWorkerBase::abandon() Q_DECL_NOEXCEPT + void CWorkerBase::abandon() noexcept { thread()->requestInterruption(); quit(); } - void CWorkerBase::abandonAndWait() Q_DECL_NOEXCEPT + void CWorkerBase::abandonAndWait() noexcept { thread()->requestInterruption(); quitAndWait(); @@ -90,13 +90,13 @@ namespace BlackMisc thread->start(priority); } - void CContinuousWorker::quit() Q_DECL_NOEXCEPT + void CContinuousWorker::quit() noexcept { Q_ASSERT_X(!CThreadUtils::isApplicationThreadObjectThread(this), Q_FUNC_INFO, "Try to stop main thread"); thread()->quit(); } - void CContinuousWorker::quitAndWait() Q_DECL_NOEXCEPT + void CContinuousWorker::quitAndWait() noexcept { Q_ASSERT_X(!CThreadUtils::isApplicationThreadObjectThread(this), Q_FUNC_INFO, "Try to stop main thread"); auto *ownThread = thread(); diff --git a/src/blackmisc/worker.h b/src/blackmisc/worker.h index 54ace1467..e64e7bf1f 100644 --- a/src/blackmisc/worker.h +++ b/src/blackmisc/worker.h @@ -159,14 +159,14 @@ namespace BlackMisc //! Blocks until the task is finished. //! \threadsafe Will deadlock if called by the worker thread. - void waitForFinished() Q_DECL_NOEXCEPT; + void waitForFinished() noexcept; //! Notify the task that its result is no longer needed, so it can finish early. //! \threadsafe - void abandon() Q_DECL_NOEXCEPT; + void abandon() noexcept; //! Convenience to call abandon() followed by waitForFinished(). - void abandonAndWait() Q_DECL_NOEXCEPT; + void abandonAndWait() noexcept; signals: //! Emitted when the task is finished. @@ -200,8 +200,8 @@ namespace BlackMisc } private: - virtual void quit() Q_DECL_NOEXCEPT {} - virtual void quitAndWait() Q_DECL_NOEXCEPT { waitForFinished(); } + virtual void quit() noexcept {} + virtual void quitAndWait() noexcept { waitForFinished(); } bool m_finished = false; mutable QMutex m_finishedMutex { QMutex::Recursive }; @@ -293,11 +293,11 @@ namespace BlackMisc //! Stops the thread the next time around its event loop. //! The thread and the worker will then be deleted. //! \threadsafe - virtual void quit() Q_DECL_NOEXCEPT final override; + virtual void quit() noexcept final override; //! Calls quit() and blocks until the thread is finished. //! \threadsafe Will deadlock if called by the worker thread. - virtual void quitAndWait() Q_DECL_NOEXCEPT final override; + virtual void quitAndWait() noexcept final override; protected slots: //! Called when the thread is started.