From 1de58ebb875d13713df24a348cbda9c339efa829 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Mon, 29 Aug 2011 11:37:22 -0500 Subject: [PATCH] Make scope gadget check if object exists before using it. Avoids segfaults when scoped objects disappear. --- .../openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp index fb2bbf796..dfbd9d614 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp @@ -385,8 +385,15 @@ void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavFieldSubField ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject(); UAVDataObject* obj = dynamic_cast(objManager->getObject((plotData->uavObject))); - + if(!obj) { + qDebug() << "Object " << plotData->uavObject << " is missing"; + return; + } UAVObjectField* field = obj->getField(plotData->uavField); + if(!field) { + qDebug() << "Field " << plotData->uavField << " of object " << plotData->uavObject << " is missing"; + return; + } QString units = field->getUnits(); if(units == 0)