From 430d60d9dfecf41bfcf651ea67569d6ab78c393e Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 6 Jan 2019 20:01:30 +0100 Subject: [PATCH] fix a crash in the new device debug prints --- libnymea-common/types/device.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libnymea-common/types/device.cpp b/libnymea-common/types/device.cpp index 2827a657..06511d2e 100644 --- a/libnymea-common/types/device.cpp +++ b/libnymea-common/types/device.cpp @@ -138,10 +138,14 @@ void Device::setStateValue(const QUuid &stateTypeId, const QVariant &value) QDebug operator<<(QDebug &dbg, Device *device) { dbg.nospace() << "Device: " << device->name() << " (" << device->id().toString() << ") Class:" << device->deviceClass()->name() << " (" << device->deviceClassId().toString() << ")" << endl; - for (int i = 0; i < device->params()->rowCount(); i++) { - Param *p = device->params()->get(i); - ParamType *pt = device->deviceClass()->paramTypes()->getParamType(p->paramTypeId()); - dbg << " Param " << i << ": " << pt->id().toString() << ": " << pt->name() << " = " << p->value() << endl; + for (int i = 0; i < device->deviceClass()->paramTypes()->rowCount(); i++) { + ParamType *pt = device->deviceClass()->paramTypes()->get(i); + Param *p = device->params()->getParam(pt->id().toString()); + if (p) { + dbg << " Param " << i << ": " << pt->id().toString() << ": " << pt->name() << " = " << p->value() << endl; + } else { + dbg << " Param " << i << ": " << pt->id().toString() << ": " << pt->name() << " = " << "*** Unknown value ***" << endl; + } } for (int i = 0; i < device->deviceClass()->stateTypes()->rowCount(); i++) { StateType *st = device->deviceClass()->stateTypes()->get(i);