diff --git a/src/models/FGBuoyantForces.cpp b/src/models/FGBuoyantForces.cpp index de0e2baac..bfa830b71 100644 --- a/src/models/FGBuoyantForces.cpp +++ b/src/models/FGBuoyantForces.cpp @@ -130,8 +130,12 @@ bool FGBuoyantForces::Load(Element *document) PostLoad(document, FDMExec); - if (!NoneDefined) { + // Load() is public and appends to the cell list, so it may be called more than + // once to add further gas cells. The properties must only be tied the first + // time: tying them again fails and logs an error for each one. + if (!NoneDefined && !isBound) { bind(); + isBound = true; } return true; diff --git a/src/models/FGBuoyantForces.h b/src/models/FGBuoyantForces.h index 3cdda4bcb..efd62e92a 100644 --- a/src/models/FGBuoyantForces.h +++ b/src/models/FGBuoyantForces.h @@ -178,6 +178,7 @@ class FGBuoyantForces : public FGModel FGColumnVector3 vXYZgasCell_arm; // [lbs in] bool NoneDefined; + bool isBound = false; void bind(void); diff --git a/src/models/FGExternalReactions.cpp b/src/models/FGExternalReactions.cpp index b58e9f9ff..606e9dc12 100644 --- a/src/models/FGExternalReactions.cpp +++ b/src/models/FGExternalReactions.cpp @@ -85,7 +85,13 @@ bool FGExternalReactions::Load(Element* el) PostLoad(el, FDMExec); - if (!Forces.empty()) bind(); + // Load() is public and may be called more than once to add further forces, so + // the properties must only be tied the first time. Tying them again fails and + // logs an error for each one. + if (!Forces.empty() && !isBound) { + bind(); + isBound = true; + } return true; } diff --git a/src/models/FGExternalReactions.h b/src/models/FGExternalReactions.h index 765ebb54a..18d4652a7 100644 --- a/src/models/FGExternalReactions.h +++ b/src/models/FGExternalReactions.h @@ -169,6 +169,7 @@ class FGExternalReactions : public FGModel //unsigned int numForces; FGColumnVector3 vTotalForces; FGColumnVector3 vTotalMoments; + bool isBound = false; void bind(void); void Debug(int from) override;