diff options
Diffstat (limited to 'src/corelib/kernel/qbasictimer.h')
-rw-r--r-- | src/corelib/kernel/qbasictimer.h | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/corelib/kernel/qbasictimer.h b/src/corelib/kernel/qbasictimer.h index bfd6ffd125..769898f835 100644 --- a/src/corelib/kernel/qbasictimer.h +++ b/src/corelib/kernel/qbasictimer.h @@ -51,12 +51,35 @@ class QObject; class Q_CORE_EXPORT QBasicTimer { int id; +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) + Q_DISABLE_COPY(QBasicTimer) +#elif QT_DEPRECATED_SINCE(5, 14) public: - inline QBasicTimer() : id(0) {} + // Just here to preserve BC, we can't remove them yet + QT_DEPRECATED_X("copy-construction is unsupported; use move-construction instead") + QBasicTimer(const QBasicTimer &); + QT_DEPRECATED_X("copy-assignment is unsupported; use move-assignment instead") + QBasicTimer &operator=(const QBasicTimer &); +#endif + +public: + constexpr QBasicTimer() noexcept : id{0} {} inline ~QBasicTimer() { if (id) stop(); } - inline bool isActive() const { return id != 0; } - inline int timerId() const { return id; } + QBasicTimer(QBasicTimer &&other) noexcept + : id{qExchange(other.id, 0)} + {} + + QBasicTimer& operator=(QBasicTimer &&other) noexcept + { + QBasicTimer{std::move(other)}.swap(*this); + return *this; + } + + void swap(QBasicTimer &other) noexcept { qSwap(id, other.id); } + + bool isActive() const noexcept { return id != 0; } + int timerId() const noexcept { return id; } void start(int msec, QObject *obj); void start(int msec, Qt::TimerType timerType, QObject *obj); @@ -64,6 +87,8 @@ public: }; Q_DECLARE_TYPEINFO(QBasicTimer, Q_MOVABLE_TYPE); +inline void swap(QBasicTimer &lhs, QBasicTimer &rhs) noexcept { lhs.swap(rhs); } + QT_END_NAMESPACE #endif // QBASICTIMER_H |