mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-03 11:24:10 +01:00
Make scope gadget check if object exists before using it. Avoids segfaults
when scoped objects disappear.
This commit is contained in:
parent
ae1dd945b1
commit
1de58ebb87
@ -385,8 +385,15 @@ void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavFieldSubField
|
|||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject((plotData->uavObject)));
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject((plotData->uavObject)));
|
||||||
|
if(!obj) {
|
||||||
|
qDebug() << "Object " << plotData->uavObject << " is missing";
|
||||||
|
return;
|
||||||
|
}
|
||||||
UAVObjectField* field = obj->getField(plotData->uavField);
|
UAVObjectField* field = obj->getField(plotData->uavField);
|
||||||
|
if(!field) {
|
||||||
|
qDebug() << "Field " << plotData->uavField << " of object " << plotData->uavObject << " is missing";
|
||||||
|
return;
|
||||||
|
}
|
||||||
QString units = field->getUnits();
|
QString units = field->getUnits();
|
||||||
|
|
||||||
if(units == 0)
|
if(units == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user