From 0aa7b835086218ea93bfc0da2526c728102d6771 Mon Sep 17 00:00:00 2001 From: Ruslan Kabatsayev Date: Thu, 6 Jul 2023 01:18:32 +0400 Subject: [PATCH] Fix behavior of DitheringMode with QVariant in Qt5 Fixes #3304 --- src/core/Dithering.hpp | 11 +++++++++++ src/core/StelCore.cpp | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/core/Dithering.hpp b/src/core/Dithering.hpp index de4d60ff992df..3eb0af982cf8e 100644 --- a/src/core/Dithering.hpp +++ b/src/core/Dithering.hpp @@ -37,6 +37,17 @@ enum class DitheringMode Color888, //!< 24-bit color (AKA True color) Color101010, //!< 30-bit color (AKA Deep color) }; +#if QT_VERSION < QT_VERSION_CHECK(5,14,0) +// A similar pair of methods but templated for arbitrary enum first appears in Qt 5.14 +inline QDataStream& operator>>(QDataStream& s, DitheringMode& m) +{ + return s >> reinterpret_cast::type&>(m); +} +inline QDataStream& operator<<(QDataStream &s, const DitheringMode &m) +{ + return s << static_cast::type>(m); +} +#endif Vec3f calcRGBMaxValue(DitheringMode mode); diff --git a/src/core/StelCore.cpp b/src/core/StelCore.cpp index dc1752e16fe98..d3a630df79015 100644 --- a/src/core/StelCore.cpp +++ b/src/core/StelCore.cpp @@ -2056,6 +2056,7 @@ void StelCore::registerMathMetaTypes() qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); + qRegisterMetaType(); #if (QT_VERSION(); qRegisterMetaTypeStreamOperators(); qRegisterMetaTypeStreamOperators(); + qRegisterMetaTypeStreamOperators(); #endif //for debugging QVariants with these types, it helps if we register the string converters // This is also required for QJSEngine.