From b77c04c99cf58d12bde8d87387c90882bb418178 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 7 Feb 2017 18:58:40 +0100 Subject: [PATCH] refs #875, fixed PQ null for DBus --- src/blackmisc/pq/physicalquantity.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/blackmisc/pq/physicalquantity.cpp b/src/blackmisc/pq/physicalquantity.cpp index 28bd7d303..b30a06180 100644 --- a/src/blackmisc/pq/physicalquantity.cpp +++ b/src/blackmisc/pq/physicalquantity.cpp @@ -34,6 +34,8 @@ #include #include #include +#include +#include namespace BlackMisc { @@ -159,7 +161,8 @@ namespace BlackMisc template void CPhysicalQuantity::marshallToDbus(QDBusArgument &argument) const { - argument << this->value(UnitClass::defaultUnit()); + constexpr double NaN = std::numeric_limits::quiet_NaN(); + argument << (this->isNull() ? NaN : this->value(UnitClass::defaultUnit())); // argument << this->m_value; // argument << this->m_unit; } @@ -168,8 +171,13 @@ namespace BlackMisc void CPhysicalQuantity::unmarshallFromDbus(const QDBusArgument &argument) { argument >> this->m_value; - // argument >> this->m_unit; this->m_unit = UnitClass::defaultUnit(); + if (std::isnan(this->m_value)) + { + this->setNull(); + } + // argument >> this->m_value; + // argument >> this->m_unit; } template @@ -251,6 +259,7 @@ namespace BlackMisc template void CPhysicalQuantity::setNull() { + this->m_value = 0; this->m_unit = MU::nullUnit(); }