summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-08-23 08:04:17 -0700
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-11-08 18:38:48 +0000
commitc5a2fa1af5c352c5e5a6cc1d7f87a7f368fd1211 (patch)
tree781a7ff4a1f3a7e781b053c026d1fdf77a043941
parent32f640ec69af4503998f75b3b796bfce78389efe (diff)
QOperatingSystemVersion: Move the new OSes into a non-exported class
The solution from commit 3446313c7a5cd6005089866a7b20c9f28e132a0a didn't work completely as expected. That commit the QOperatingSystemVersionBase base class so we could add new static constexpr inline variables to QOperatingSystemVersion in patch releases. We need a different base class because you can't have constexpr variables of incomplete types and the the type isn't complete inside its definition. However, QOperatingSystemVersion is an exported class and there's an unexpected interaction between __declspec(dllexport) / dllimport and inline variables: they're imported from the DLL that exported them. For Qt 7 we can remove this class's export, but not until then. This commit adds to the fix by introducing a middle base class, so we can add the static constexpr inline variables. Pick-to: 6.6.0 Change-Id: Ifa1111900d6945ea8e05fffd177e0b696209c7af Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 215677818470e48e9090d7ae4411e1fea62207b8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/corelib/global/qoperatingsystemversion.cpp1
-rw-r--r--src/corelib/global/qoperatingsystemversion.h48
2 files changed, 34 insertions, 15 deletions
diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp
index 0a68846f2f..843a5dbfad 100644
--- a/src/corelib/global/qoperatingsystemversion.cpp
+++ b/src/corelib/global/qoperatingsystemversion.cpp
@@ -563,7 +563,6 @@ const QOperatingSystemVersionBase QOperatingSystemVersion::MacOSVentura;
\brief a version corresponding to macOS Sonoma (version 14).
\since 6.5
*/
-const QOperatingSystemVersionBase QOperatingSystemVersion::MacOSSonoma;
/*!
\variable QOperatingSystemVersion::AndroidJellyBean
diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h
index dc830f9736..bb46f0dbc9 100644
--- a/src/corelib/global/qoperatingsystemversion.h
+++ b/src/corelib/global/qoperatingsystemversion.h
@@ -9,6 +9,12 @@
QT_BEGIN_NAMESPACE
+#if 0
+# pragma qt_class(QOperatingSystemVersionBase)
+# pragma qt_class(QOperatingSystemVersion)
+# pragma qt_sync_stop_processing // we have some ifdef'ery fooling syncqt
+#endif
+
class QString;
class QOperatingSystemVersionBase
@@ -85,6 +91,7 @@ public:
friend bool operator<=(QOperatingSystemVersionBase lhs, QOperatingSystemVersionBase rhs)
{ return lhs.type() == rhs.type() && QOperatingSystemVersionBase::compare(lhs, rhs) <= 0; }
+
protected:
static Q_CORE_EXPORT int compare(QOperatingSystemVersionBase v1,
QOperatingSystemVersionBase v2);
@@ -93,17 +100,33 @@ protected:
private:
static QOperatingSystemVersionBase current_impl();
-
OSType m_os;
int m_major;
int m_minor;
int m_micro;
};
-// ### Qt 7: Un-export the class, export relevant functions. Remove the enum.
-class Q_CORE_EXPORT QOperatingSystemVersion : public QOperatingSystemVersionBase
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED) && !defined(Q_QDOC)
+class QOperatingSystemVersionUnexported : public QOperatingSystemVersionBase
{
public:
+ using QOperatingSystemVersionBase::QOperatingSystemVersionBase;
+#else
+class QOperatingSystemVersion : public QOperatingSystemVersionBase
+{
+ using QOperatingSystemVersionUnexported = QOperatingSystemVersionBase;
+#endif
+
+ // ### Qt7: Regroup with the rest below
+ static constexpr QOperatingSystemVersionBase MacOSSonoma { QOperatingSystemVersionBase::MacOS, 14, 0 };
+
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED) && !defined(Q_QDOC)
+};
+
+class Q_CORE_EXPORT QOperatingSystemVersion : public QOperatingSystemVersionUnexported
+{
+#endif
+public:
// ### Qt7: Remove. Keep synchronized with QOperatingSystemVersionBase::OSType until then!
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
enum OSType {
@@ -117,11 +140,9 @@ public:
};
#endif
- // ### Qt7: remove the branch with static const variables. Then group and sort the inline ones.
- // Since the exported variables emit symbols they cannot be cherry-picked back to patch-releases
- // without breaking our BC promises. They must be fully inline but we cannot make that change
- // until Qt7
- // @note: New entries should be added after the if-def-ery until Qt 7!!
+ // ### Qt7: remove the branch with static const variables. Then group and
+ // sort the inline ones. Until then, new entries should be added to
+ // QOperatingSystemVersionUnexported.
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
static const QOperatingSystemVersion Windows7;
static const QOperatingSystemVersion Windows8;
@@ -182,7 +203,7 @@ public:
static constexpr QOperatingSystemVersionBase AndroidPie { QOperatingSystemVersionBase::Android, 9, 0 };
static constexpr QOperatingSystemVersionBase Android10 { QOperatingSystemVersionBase::Android, 10, 0 };
static constexpr QOperatingSystemVersionBase Android11 { QOperatingSystemVersionBase::Android, 11, 0 };
-#endif // New (static constexpr) entries go here, only cherry-pick as far back as 6.3 (QTBUG-97808):
+#endif
static constexpr QOperatingSystemVersionBase Windows10_1809 { QOperatingSystemVersionBase::Windows, 10, 0, 17763 }; // RS5
static constexpr QOperatingSystemVersionBase Windows10_1903 { QOperatingSystemVersionBase::Windows, 10, 0, 18362 }; // 19H1
@@ -201,13 +222,12 @@ public:
static constexpr QOperatingSystemVersionBase Android13 { QOperatingSystemVersionBase::Android, 13, 0 };
static constexpr QOperatingSystemVersionBase MacOSVentura { QOperatingSystemVersionBase::MacOS, 13, 0 };
- static constexpr QOperatingSystemVersionBase MacOSSonoma { QOperatingSystemVersionBase::MacOS, 14, 0 };
constexpr QOperatingSystemVersion(const QOperatingSystemVersionBase &osversion)
- : QOperatingSystemVersionBase(osversion) {}
+ : QOperatingSystemVersionUnexported(static_cast<const QOperatingSystemVersionUnexported &>(osversion)) {}
constexpr QOperatingSystemVersion(OSType osType, int vmajor, int vminor = -1, int vmicro = -1)
- : QOperatingSystemVersionBase(QOperatingSystemVersionBase::OSType(osType), vmajor, vminor,
+ : QOperatingSystemVersionUnexported(QOperatingSystemVersionBase::OSType(osType), vmajor, vminor,
vmicro)
{
}
@@ -229,8 +249,8 @@ public:
{ return QOperatingSystemVersionBase::segmentCount(); }
constexpr OSType type() const { return OSType(QOperatingSystemVersionBase::type()); }
- bool isAnyOfType(std::initializer_list<OSType> types) const;
- QString name() const;
+ QT7_ONLY(Q_CORE_EXPORT) bool isAnyOfType(std::initializer_list<OSType> types) const;
+ QT7_ONLY(Q_CORE_EXPORT) QString name() const;
private:
QOperatingSystemVersion() = default;