Skip to content

Commit 049c19e

Browse files
authored
Fixes issue #2903 (#2907)
This PR fixes issue #2903 and prevents the server from segfaulting if the plugin fails to load correctly. It prints an error that the plugin was misconfigured and continues executing ahead. Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai>
1 parent 9f9d83c commit 049c19e

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/systems/lift_drag/LiftDrag.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ class gz::sim::systems::LiftDragPrivate
148148
void LiftDragPrivate::Load(const EntityComponentManager &_ecm,
149149
const sdf::ElementPtr &_sdf)
150150
{
151+
if (!this->model.Valid(_ecm))
152+
{
153+
gzerr << "The LiftDrag system should be attached to a model entity. "
154+
<< "Failed to initialize." << std::endl;
155+
return;
156+
}
151157
this->cla = _sdf->Get<double>("cla", this->cla).first;
152158
this->cda = _sdf->Get<double>("cda", this->cda).first;
153159
this->cma = _sdf->Get<double>("cma", this->cma).first;
@@ -529,15 +535,9 @@ void LiftDragPrivate::Update(EntityComponentManager &_ecm)
529535
//////////////////////////////////////////////////
530536
void LiftDrag::Configure(const Entity &_entity,
531537
const std::shared_ptr<const sdf::Element> &_sdf,
532-
EntityComponentManager &_ecm, EventManager &)
538+
EntityComponentManager &, EventManager &)
533539
{
534540
this->dataPtr->model = Model(_entity);
535-
if (!this->dataPtr->model.Valid(_ecm))
536-
{
537-
gzerr << "The LiftDrag system should be attached to a model entity. "
538-
<< "Failed to initialize." << std::endl;
539-
return;
540-
}
541541
this->dataPtr->sdfConfig = _sdf->Clone();
542542
}
543543

0 commit comments

Comments
 (0)