From 4c3c6bab302b610ce0457f96fd0a04842d25b692 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sun, 26 Jul 2015 14:45:49 +0200 Subject: QTimer: Force a compilation error with pmf without object None of this should compile (foo is non-static): QTimer::singleShot(0, &TestObject::foo); QTimer::singleShot(0, SLOT(foo())); Task-number: QTBUG-47426 Change-Id: I54b7d14124459e450c6a0a93a3033f21b57605d9 Reviewed-by: Dario Freddi Reviewed-by: Thiago Macieira --- src/corelib/kernel/qtimer.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index 56f8a1a177..889f5d7f70 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -102,12 +102,16 @@ public: } // singleShot to a functor or function pointer (without context) template - static inline void singleShot(int msec, Func1 slot) + static inline typename QtPrivate::QEnableIf::IsPointerToMemberFunction && + !QtPrivate::is_same::value, void>::Type + singleShot(int msec, Func1 slot) { singleShot(msec, msec >= 2000 ? Qt::CoarseTimer : Qt::PreciseTimer, Q_NULLPTR, slot); } template - static inline void singleShot(int msec, Qt::TimerType timerType, Func1 slot) + static inline typename QtPrivate::QEnableIf::IsPointerToMemberFunction && + !QtPrivate::is_same::value, void>::Type + singleShot(int msec, Qt::TimerType timerType, Func1 slot) { singleShot(msec, timerType, Q_NULLPTR, slot); } -- cgit v1.2.3