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
This commit is contained in:
parent
47e3f9f7c7
commit
ecc952d235
|
@ -14,6 +14,12 @@
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define V_UNUSED __attribute__ ((unused))
|
||||||
|
#else
|
||||||
|
#define V_UNUSED
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef std::function<void()> voidBlock;
|
typedef std::function<void()> voidBlock;
|
||||||
|
|
||||||
class WorkerClass : public QObject
|
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>("voidBlock");
|
qRegisterMetaType<voidBlock>("voidBlock");
|
||||||
|
|
||||||
|
@ -42,7 +49,8 @@ static void q_dispatch_async(QThread* thread, voidBlock block)
|
||||||
QMetaObject::invokeMethod(worker, "DoWork", Qt::QueuedConnection, Q_ARG(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();
|
QThread *mainThread = QCoreApplication::instance()->thread();
|
||||||
q_dispatch_async(mainThread, block);
|
q_dispatch_async(mainThread, block);
|
||||||
|
@ -84,8 +92,10 @@ private:
|
||||||
QString m_category;
|
QString m_category;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void q_dispatch_async(QThread* thread, msgHandlerBlock block, QtMsgType type, const QMessageLogContext &context,
|
static inline void q_dispatch_async(QThread* thread, msgHandlerBlock block, QtMsgType type,
|
||||||
const QString &msg)
|
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>("msgHandlerBlock");
|
qRegisterMetaType<msgHandlerBlock>("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));
|
QMetaObject::invokeMethod(worker, "DoWork", Qt::QueuedConnection, Q_ARG(msgHandlerBlock, block));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void q_dispatch_async_main(msgHandlerBlock block, QtMsgType type, const QMessageLogContext &context,
|
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)
|
const QString &msg)
|
||||||
{
|
{
|
||||||
QThread *mainThread = QCoreApplication::instance()->thread();
|
QThread *mainThread = QCoreApplication::instance()->thread();
|
||||||
q_dispatch_async(mainThread, block, type, context, msg);
|
q_dispatch_async(mainThread, block, type, context, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef V_UNUSED
|
||||||
|
|
||||||
#endif // THREAD_DISPATCHER_H
|
#endif // THREAD_DISPATCHER_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user