From b6b945abb5695ac3d8b841a21249e748bb9ba715 Mon Sep 17 00:00:00 2001 From: Rajat Singhal Date: Sun, 7 Mar 2021 13:44:58 +0530 Subject: [PATCH 1/2] Signal: Fix crash due to erase during iteration --- AirLib/include/common/common_utils/Signal.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AirLib/include/common/common_utils/Signal.hpp b/AirLib/include/common/common_utils/Signal.hpp index a3f550c971..1eea59077b 100644 --- a/AirLib/include/common/common_utils/Signal.hpp +++ b/AirLib/include/common/common_utils/Signal.hpp @@ -81,8 +81,9 @@ class Signal { // calls all connected functions void emit(Args... p) { - for (auto it : slots_) { - it.second(p...); + for(auto it=slots_.begin(); it!=slots_.end(); ) { + // Increment here so that the entry can be erased from inside the method as well + (it++)->second(p...); } } From 424190e2d795f1b702f54427d5dcde2a33c7cb83 Mon Sep 17 00:00:00 2001 From: Rajat Singhal Date: Sun, 7 Mar 2021 13:47:03 +0530 Subject: [PATCH 2/2] Perform some cleanup in FlyingPawn --- .../Plugins/AirSim/Source/Vehicles/Multirotor/FlyingPawn.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Unreal/Plugins/AirSim/Source/Vehicles/Multirotor/FlyingPawn.cpp b/Unreal/Plugins/AirSim/Source/Vehicles/Multirotor/FlyingPawn.cpp index a41677abf6..493eba77da 100644 --- a/Unreal/Plugins/AirSim/Source/Vehicles/Multirotor/FlyingPawn.cpp +++ b/Unreal/Plugins/AirSim/Source/Vehicles/Multirotor/FlyingPawn.cpp @@ -45,6 +45,9 @@ void AFlyingPawn::EndPlay(const EEndPlayReason::Type EndPlayReason) camera_back_center_ = nullptr; camera_bottom_center_ = nullptr; + pawn_events_.getActuatorSignal().disconnect_all(); + rotating_movements_.Empty(); + Super::EndPlay(EndPlayReason); }