From 1af36eb230da4cde7a8ce4addb9f4772922b7fa4 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 3 May 2023 15:09:32 +0200 Subject: [PATCH] Doc: fix warnings in QTimer Amends recent changes that added std::chrono support by making the duration type of QTimer::singleShot a template parameter. Change-Id: If3b5f0ad99304cb292412bb8467ba6852e47654f Reviewed-by: Thiago Macieira --- src/corelib/kernel/qtimer.cpp | 29 ++++++++--------------------- src/corelib/kernel/qtimer.h | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 35 deletions(-) diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp index 2e7382d051..a1abe71052 100644 --- a/src/corelib/kernel/qtimer.cpp +++ b/src/corelib/kernel/qtimer.cpp @@ -441,10 +441,10 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv } } -/*! \fn template void QTimer::singleShot(int msec, const QObject *context, Functor &&functor) - \fn template void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *context, Functor &&functor) - \fn template void QTimer::singleShot(int msec, Functor &&functor) - \fn template void QTimer::singleShot(int msec, Qt::TimerType timerType, Functor &&functor) +/*! \fn template void QTimer::singleShot(Duration msec, const QObject *context, Functor &&functor) + \fn template void QTimer::singleShot(Duration msec, Qt::TimerType timerType, const QObject *context, Functor &&functor) + \fn template void QTimer::singleShot(Duration msec, Functor &&functor) + \fn template void QTimer::singleShot(Duration msec, Qt::TimerType timerType, Functor &&functor) \since 5.4 \reentrant @@ -462,6 +462,8 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv If \a functor is a member function of \a context, then the function will be called on the object. + The \a msec parameter can be an \c int or a \c std::chrono::milliseconds value. + \sa start() */ @@ -503,9 +505,8 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv */ /*! - \fn template QMetaObject::Connection QTimer::callOnTimeout(Functor slot, Qt::ConnectionType connectionType = Qt::AutoConnection) + \fn template QMetaObject::Connection QTimer::callOnTimeout(Functor &&slot, Qt::ConnectionType connectionType = Qt::AutoConnection) \since 5.12 - \overload Creates a connection of type \a connectionType from the timeout() signal to \a slot, and returns a handle to the connection. @@ -517,7 +518,7 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv */ /*! - \fn template QMetaObject::Connection QTimer::callOnTimeout(const QObject *context, Functor slot, Qt::ConnectionType connectionType = Qt::AutoConnection) + \fn template QMetaObject::Connection QTimer::callOnTimeout(const QObject *context, Functor &&slot, Qt::ConnectionType connectionType = Qt::AutoConnection) \since 5.12 \overload callOnTimeout() @@ -530,20 +531,6 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv \sa QObject::connect(), timeout() */ -/*! - \fn template QMetaObject::Connection QTimer::callOnTimeout(const QObject *receiver, MemberFunction *slot, Qt::ConnectionType connectionType = Qt::AutoConnection) - \since 5.12 - \overload callOnTimeout() - - Creates a connection from the timeout() signal to the \a slot in the \a receiver object. Returns - a handle to the connection. - - This method is provided for convenience. It's equivalent to calling - \c {QObject::connect(timer, &QTimer::timeout, receiver, slot, connectionType)}. - - \sa QObject::connect(), timeout() -*/ - /*! \fn void QTimer::start(std::chrono::milliseconds msec) \since 5.8 diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index 829d58a7c2..4c70ab2562 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -50,41 +50,41 @@ public: static void singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, const char *member); // singleShot with context - template + template static inline void singleShot(Duration interval, #ifdef Q_QDOC const QObject *receiver, #else - const typename QtPrivate::ContextTypeForFunctor::ContextType *receiver, + const typename QtPrivate::ContextTypeForFunctor::ContextType *receiver, #endif - Func1 &&slot) + Functor &&slot) { - singleShot(interval, defaultTypeFor(interval), receiver, std::forward(slot)); + singleShot(interval, defaultTypeFor(interval), receiver, std::forward(slot)); } - template + template static inline void singleShot(Duration interval, Qt::TimerType timerType, #ifdef Q_QDOC const QObject *receiver, #else - const typename QtPrivate::ContextTypeForFunctor::ContextType *receiver, + const typename QtPrivate::ContextTypeForFunctor::ContextType *receiver, #endif - Func1 &&slot) + Functor &&slot) { using Prototype = void(*)(); singleShotImpl(interval, timerType, receiver, - QtPrivate::makeSlotObject(std::forward(slot))); + QtPrivate::makeSlotObject(std::forward(slot))); } // singleShot without context - template - static inline void singleShot(Duration interval, Func1 &&slot) + template + static inline void singleShot(Duration interval, Functor &&slot) { - singleShot(interval, defaultTypeFor(interval), nullptr, std::forward(slot)); + singleShot(interval, defaultTypeFor(interval), nullptr, std::forward(slot)); } - template - static inline void singleShot(Duration interval, Qt::TimerType timerType, Func1 &&slot) + template + static inline void singleShot(Duration interval, Qt::TimerType timerType, Functor &&slot) { - singleShot(interval, timerType, nullptr, std::forward(slot)); + singleShot(interval, timerType, nullptr, std::forward(slot)); } #ifdef Q_QDOC