QTimer: restore BC with Qt 6.7 for MSVC

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 <thiago.macieira@intel.com>
(cherry picked from commit 27ed0014b491f457469914847f0a41926af998f4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2025-04-03 14:43:36 +02:00 committed by Qt Cherry-pick Bot
parent c5beecbcc0
commit bb46df6a7a
2 changed files with 8 additions and 0 deletions

View File

@ -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)

View File

@ -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