Skip to content

Commit

Permalink
Fix behavior of DitheringMode with QVariant in Qt5
Browse files Browse the repository at this point in the history
Fixes #3304
  • Loading branch information
10110111 committed Jul 6, 2023
1 parent 26ab36d commit e49a0dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core/Dithering.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ 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 method but templated for arbitrary enum first appears in Qt 5.14
inline QDataStream& operator>>(QDataStream& s, DitheringMode& m)
{
return s >> reinterpret_cast<std::underlying_type<DitheringMode>::type&>(m);
}
#endif

Vec3f calcRGBMaxValue(DitheringMode mode);

Expand Down
2 changes: 2 additions & 0 deletions src/core/StelCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,7 @@ void StelCore::registerMathMetaTypes()
qRegisterMetaType<Mat4f>();
qRegisterMetaType<Mat3d>();
qRegisterMetaType<Mat3f>();
qRegisterMetaType<DitheringMode>();

#if (QT_VERSION<QT_VERSION_CHECK(6,0,0))
//registers the QDataStream operators, so that QVariants with these types can be saved
Expand All @@ -2072,6 +2073,7 @@ void StelCore::registerMathMetaTypes()
qRegisterMetaTypeStreamOperators<Mat4f>();
qRegisterMetaTypeStreamOperators<Mat3d>();
qRegisterMetaTypeStreamOperators<Mat3f>();
qRegisterMetaTypeStreamOperators<DitheringMode>();
#endif
//for debugging QVariants with these types, it helps if we register the string converters
// This is also required for QJSEngine.
Expand Down

0 comments on commit e49a0dc

Please sign in to comment.