diff --git a/rmw_fastrtps_cpp/src/init_rmw_context_impl.cpp b/rmw_fastrtps_cpp/src/init_rmw_context_impl.cpp index 49f1dc1d6..f32f783ed 100644 --- a/rmw_fastrtps_cpp/src/init_rmw_context_impl.cpp +++ b/rmw_fastrtps_cpp/src/init_rmw_context_impl.cpp @@ -151,13 +151,6 @@ init_context_impl(rmw_context_t * context) return RMW_RET_BAD_ALLOC; } - common_context->graph_cache.set_on_change_callback( - [guard_condition = graph_guard_condition.get()]() { - rmw_fastrtps_shared_cpp::__rmw_trigger_guard_condition( - eprosima_fastrtps_identifier, - guard_condition); - }); - common_context->gid = rmw_fastrtps_shared_cpp::create_rmw_gid( eprosima_fastrtps_identifier, participant_info->participant->getGuid()); common_context->pub = publisher.get(); @@ -171,6 +164,14 @@ init_context_impl(rmw_context_t * context) if (RMW_RET_OK != ret) { return ret; } + + common_context->graph_cache.set_on_change_callback( + [guard_condition = graph_guard_condition.get()]() { + rmw_fastrtps_shared_cpp::__rmw_trigger_guard_condition( + eprosima_fastrtps_identifier, + guard_condition); + }); + common_context->graph_cache.add_participant( common_context->gid, context->options.enclave); diff --git a/rmw_fastrtps_dynamic_cpp/src/init_rmw_context_impl.cpp b/rmw_fastrtps_dynamic_cpp/src/init_rmw_context_impl.cpp index 6428483d5..0d4a398a5 100644 --- a/rmw_fastrtps_dynamic_cpp/src/init_rmw_context_impl.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/init_rmw_context_impl.cpp @@ -151,14 +151,6 @@ init_context_impl(rmw_context_t * context) return RMW_RET_BAD_ALLOC; } - common_context->graph_cache.set_on_change_callback( - [guard_condition = graph_guard_condition.get()]() { - rmw_fastrtps_shared_cpp::__rmw_trigger_guard_condition( - eprosima_fastrtps_identifier, - guard_condition); - }); - - common_context->gid = rmw_fastrtps_shared_cpp::create_rmw_gid( eprosima_fastrtps_identifier, participant_info->participant->getGuid()); common_context->pub = publisher.get(); @@ -172,6 +164,14 @@ init_context_impl(rmw_context_t * context) if (RMW_RET_OK != ret) { return ret; } + + common_context->graph_cache.set_on_change_callback( + [guard_condition = graph_guard_condition.get()]() { + rmw_fastrtps_shared_cpp::__rmw_trigger_guard_condition( + eprosima_fastrtps_identifier, + guard_condition); + }); + common_context->graph_cache.add_participant( common_context->gid, context->options.enclave);