From ecc952d2351799fa8f4decfa0333099455e18709 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 28 Sep 2018 22:29:58 +0300 Subject: [PATCH] Suppressing error: 'void q_dispatch_async_main(voidBlock)' defined but not used [-Werror=unused-function]. First, because this is static function define it inline. Second, use GCC extension to fully cover possible cases with Clang. --HG-- branch : release --- src/libs/vmisc/qt_dispatch/qt_dispatch.h | 26 ++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/libs/vmisc/qt_dispatch/qt_dispatch.h b/src/libs/vmisc/qt_dispatch/qt_dispatch.h index 744ea35d8..ae630ee0f 100644 --- a/src/libs/vmisc/qt_dispatch/qt_dispatch.h +++ b/src/libs/vmisc/qt_dispatch/qt_dispatch.h @@ -14,6 +14,12 @@ #include +#ifdef __GNUC__ +#define V_UNUSED __attribute__ ((unused)) +#else +#define V_UNUSED +#endif + typedef std::function voidBlock; class WorkerClass : public QObject @@ -34,7 +40,8 @@ public slots: } }; -static void q_dispatch_async(QThread* thread, voidBlock block) +static inline void q_dispatch_async(QThread* thread, voidBlock block) V_UNUSED; +static inline void q_dispatch_async(QThread* thread, voidBlock block) { qRegisterMetaType("voidBlock"); @@ -42,7 +49,8 @@ static void q_dispatch_async(QThread* thread, voidBlock block) QMetaObject::invokeMethod(worker, "DoWork", Qt::QueuedConnection, Q_ARG(voidBlock, block)); } -static void q_dispatch_async_main(voidBlock block) +static inline void q_dispatch_async_main(voidBlock block) V_UNUSED; +static inline void q_dispatch_async_main(voidBlock block) { QThread *mainThread = QCoreApplication::instance()->thread(); q_dispatch_async(mainThread, block); @@ -84,8 +92,10 @@ private: QString m_category; }; -static void q_dispatch_async(QThread* thread, msgHandlerBlock block, QtMsgType type, const QMessageLogContext &context, - const QString &msg) +static inline void q_dispatch_async(QThread* thread, msgHandlerBlock block, QtMsgType type, + const QMessageLogContext &context, const QString &msg) V_UNUSED; +static inline void q_dispatch_async(QThread* thread, msgHandlerBlock block, QtMsgType type, + const QMessageLogContext &context, const QString &msg) { qRegisterMetaType("msgHandlerBlock"); @@ -93,11 +103,15 @@ static void q_dispatch_async(QThread* thread, msgHandlerBlock block, QtMsgType t QMetaObject::invokeMethod(worker, "DoWork", Qt::QueuedConnection, Q_ARG(msgHandlerBlock, block)); } -static void q_dispatch_async_main(msgHandlerBlock block, QtMsgType type, const QMessageLogContext &context, - const QString &msg) +static inline void q_dispatch_async_main(msgHandlerBlock block, QtMsgType type, const QMessageLogContext &context, + const QString &msg) V_UNUSED; +static inline void q_dispatch_async_main(msgHandlerBlock block, QtMsgType type, const QMessageLogContext &context, + const QString &msg) { QThread *mainThread = QCoreApplication::instance()->thread(); q_dispatch_async(mainThread, block, type, context, msg); } +#undef V_UNUSED + #endif // THREAD_DISPATCHER_H