File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Source/ROSIntegration/Private Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 88#include " Kismet/GameplayStatics.h"
99
1010
11+ static void UnsubscribeAndUnadvertiseAllTopics ()
12+ {
13+ for (TObjectIterator<UTopic> It; It; ++It)
14+ {
15+ UTopic* Topic = *It;
16+ Topic->Unadvertise (); // to make sure all topics are unadvertised on ROS side
17+ Topic->Unsubscribe (); // to prevent messages arriving during shutdown from triggering subscription callbacks
18+ Topic->MarkAsDisconnected ();
19+ }
20+ }
21+
1122static void MarkAllROSObjectsAsDisconnected ()
1223{
1324 for (TObjectIterator<UTopic> It; It; ++It)
@@ -187,6 +198,7 @@ void UROSIntegrationGameInstance::Shutdown()
187198 FWorldDelegates::OnWorldTickStart.RemoveAll (this );
188199 }
189200
201+ UnsubscribeAndUnadvertiseAllTopics (); // make sure no subscription callbacks are fired during shutdown
190202 MarkAllROSObjectsAsDisconnected (); // moved here from UROSIntegrationGameInstance::BeginDestroy()
191203
192204 UE_LOG (LogROS, Display, TEXT (" ROS Game Instance - shutdown done" ));
You can’t perform that action at this time.
0 commit comments