Skip to content

Commit

Permalink
Expose rendering teardown event (#1539)
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <[email protected]>
  • Loading branch information
hidmic authored Jun 21, 2022
1 parent f5f753e commit 171e486
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/gz/sim/rendering/Events.hh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ namespace gz
using PostRender = gz::common::EventT<void(void),
struct PostRenderTag>;

/// \brief The render teardown event is emitted right before the
/// rendering thread is torn down. The event is emitted in the
/// rendering thread so last minute, cleanup rendering calls can
/// be made in this event callback.
///
/// For example:
/// \code
/// eventManager.Emit<gz::sim::events::RenderTeardown>();
/// \endcode
using RenderTeardown = gz::common::EventT<void(void),
struct RenderTeardownTag>;

/// \brief The force render event may be emitted outside the
/// rendering thread to force rendering calls ie. to ensure
/// rendering occurs even if it wasn't seemingly necessary.
Expand Down
2 changes: 2 additions & 0 deletions src/systems/sensors/Sensors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ void SensorsPrivate::RenderThread()
this->RunOnce();
}

this->eventManager->Emit<events::RenderTeardown>();

// clean up before exiting
for (const auto id : this->sensorIds)
this->sensorManager.Remove(id);
Expand Down

0 comments on commit 171e486

Please sign in to comment.