Skip to content

Commit fe95598

Browse files
committed
temporary patch for race condition
Signed-off-by: Ashton Larkin <[email protected]>
1 parent 4c5afe6 commit fe95598

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

include/ignition/gazebo/detail/EntityComponentManager.hh

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <cstring>
2121
#include <map>
2222
#include <memory>
23+
#include <mutex>
2324
#include <optional>
2425
#include <set>
2526
#include <tuple>
@@ -486,6 +487,9 @@ void EntityComponentManager::EachRemoved(typename identity<std::function<
486487
template<typename ...ComponentTypeTs>
487488
detail::View<ComponentTypeTs...> *EntityComponentManager::FindView() const
488489
{
490+
static std::mutex mutex;
491+
std::lock_guard<std::mutex> lock(mutex);
492+
489493
auto viewKey = std::vector<ComponentTypeId>{ComponentTypeTs::typeId...};
490494

491495
auto baseViewPtr = this->FindView(viewKey);
@@ -494,6 +498,7 @@ detail::View<ComponentTypeTs...> *EntityComponentManager::FindView() const
494498
auto view = static_cast<detail::View<ComponentTypeTs...>*>(baseViewPtr);
495499

496500
// add any new entities to the view before using it
501+
view->ToAddEntities();
497502
for (const auto &[entity, isNew] : view->ToAddEntities())
498503
{
499504
view->AddEntityWithConstComps(entity, isNew,

0 commit comments

Comments
 (0)