Skip to content

Commit

Permalink
Special dart destructor doesn't work with static linking
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
  • Loading branch information
mjcarroll committed Feb 6, 2024
1 parent 45a0de5 commit 1491536
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions dartsim/src/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class Plugin :
public virtual SimulationFeatures,
public virtual WorldFeatures { };

#ifndef GZ_PHYSICS_BAZEL_BUILD
namespace {

// This is done as a partial fix for
// https://github.com/gazebosim/gz-physics/issues/442. The issue seems like the
// destructors for the concrete collision detectors get unloaded and deleted
Expand All @@ -80,12 +80,18 @@ struct UnregisterCollisionDetectors
{
~UnregisterCollisionDetectors()
{
dart::collision::CollisionDetector::getFactory()->unregisterAllCreators();
auto factory = dart::collision::CollisionDetector::getFactory();

if (factory != nullptr)
{
factory->unregisterAllCreators();
}
}
};

UnregisterCollisionDetectors unregisterAtUnload;
}
} // namespace
#endif // GZ_PHYSICS_BAZEL_BUILD

GZ_PHYSICS_ADD_PLUGIN(Plugin, FeaturePolicy3d, DartsimFeatures)

Expand Down

0 comments on commit 1491536

Please sign in to comment.