diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/subsurface-qt/DiveObjectHelper.cpp | 7 | ||||
-rw-r--r-- | core/subsurface-qt/DiveObjectHelper.h | 7 |
2 files changed, 11 insertions, 3 deletions
diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp index e4945f007..c19c03eb4 100644 --- a/core/subsurface-qt/DiveObjectHelper.cpp +++ b/core/subsurface-qt/DiveObjectHelper.cpp @@ -55,6 +55,13 @@ static QString getPressures(struct dive *dive, int i, enum returnPressureSelecto return fmt; } +// Qt's metatype system insists on generating a default constructed object, +// even if that makes no sense. Usage of this object *will* crash. +DiveObjectHelper::DiveObjectHelper() : + m_dive(nullptr) +{ +} + DiveObjectHelper::DiveObjectHelper(struct dive *d) : m_dive(d) { diff --git a/core/subsurface-qt/DiveObjectHelper.h b/core/subsurface-qt/DiveObjectHelper.h index 397bc4d36..7071c1580 100644 --- a/core/subsurface-qt/DiveObjectHelper.h +++ b/core/subsurface-qt/DiveObjectHelper.h @@ -9,8 +9,8 @@ #include <QVector> #include <QVariant> -class DiveObjectHelper : public QObject { - Q_OBJECT +class DiveObjectHelper { + Q_GADGET Q_PROPERTY(int number READ number CONSTANT) Q_PROPERTY(int id READ id CONSTANT) Q_PROPERTY(int rating READ rating CONSTANT) @@ -48,6 +48,7 @@ class DiveObjectHelper : public QObject { Q_PROPERTY(QStringList endPressure READ endPressure CONSTANT) Q_PROPERTY(QStringList firstGas READ firstGas CONSTANT) public: + DiveObjectHelper(); // This is only to be used by Qt's metatype system! DiveObjectHelper(struct dive *dive); int number() const; int id() const; @@ -92,6 +93,6 @@ public: private: struct dive *m_dive; }; - Q_DECLARE_METATYPE(DiveObjectHelper *) + Q_DECLARE_METATYPE(DiveObjectHelper) #endif |