From bb46df6a7aa6b0d7e797f0deefc93584e36f00b6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 3 Apr 2025 14:43:36 +0200 Subject: [PATCH] QTimer: restore BC with Qt 6.7 for MSVC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When I ported the QTimer::defaultTypeFor() helper from ms to ns granularity, I failed to account for MSVC, in which inline functions of exported classes are themselves exported. As a consequence, the private QTimer::defaultTypeFor(milliseconds) symbol went missing. To fix, re-add it as REMOVED_SINCE API. We don't need to play tricks with QT6_*_NEW_OVERLOAD here, since the overloads have a different signature and the only callers¹ are either passing an exact ms or ns argument² or are in dependent names in templates³ which removed_api.cpp does not instantiate. ¹ this is a private function, so we don't need to look very far... ² the string-based singleShot() overloads ³ and so name lookup (and therefore overload resolution) happens only at instantiation time, not at template parse time (so Integrity and VxWorks compilers will, that is) Amends a60e341145a3b8a106e556e17ae62d2f45ac5d74. Pick-to: 6.8 Fixes: QTBUG-135578 Change-Id: I375e6f04a3af3824f980fe59775d3eea94250987 Reviewed-by: Thiago Macieira (cherry picked from commit 27ed0014b491f457469914847f0a41926af998f4) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/compat/removed_api.cpp | 1 + src/corelib/kernel/qtimer.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index cf96ac41e1a..5a659077e5c 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -1165,6 +1165,7 @@ auto QStringConverter::encodingForName(const char *name) noexcept -> std::option #endif #include "qtimer.h" // inlined API + // removed inline API (MSVC) void QTimer::singleShot(std::chrono::milliseconds interval, Qt::TimerType timerType, const QObject *receiver, const char *member) diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index 0faaab5f601..00c6b7bf127 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -160,6 +160,13 @@ private: static constexpr Qt::TimerType defaultTypeFor(int msecs) noexcept { return defaultTypeFor(std::chrono::milliseconds{msecs}); } +#if QT_CORE_REMOVED_SINCE(6, 8) + static constexpr Qt::TimerType defaultTypeFor(std::chrono::milliseconds interval) noexcept + { + return defaultTypeFor(std::chrono::nanoseconds{interval}); + } +#endif + static constexpr Qt::TimerType defaultTypeFor(std::chrono::nanoseconds interval) noexcept { // coarse timers are worst in their first firing