From 048a2987b270fe7adaacd22158fd88584f9fc56f Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Fri, 29 Aug 2025 12:56:14 -0700 Subject: [PATCH] Update logic for setting initial state (#3044) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ian Chen Co-authored-by: Alejandro Hernández Cordero (cherry picked from commit 6529f3f7b380ebc390b5a99b2c2b6fc77edd349c) Signed-off-by: Ian Chen # Conflicts: # src/gui/GuiRunner.cc --- src/gui/GuiRunner.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/GuiRunner.cc b/src/gui/GuiRunner.cc index 3d9ff89796..426c30c11f 100644 --- a/src/gui/GuiRunner.cc +++ b/src/gui/GuiRunner.cc @@ -74,7 +74,7 @@ class gz::sim::GuiRunner::Implementation public: std::thread updateThread; /// \brief True if the initial state has been received and processed. - public: bool receivedInitialState{false}; + public: std::atomic receivedInitialState{false}; /// \brief Name of WorldControl service public: std::string controlService; @@ -264,7 +264,6 @@ void GuiRunner::OnStateAsyncService(const msgs::SerializedStepMap &_res) // variables. QMetaObject::invokeMethod(this, "OnStateQt", Qt::QueuedConnection, Q_ARG(msgs::SerializedStepMap, _res)); - this->dataPtr->receivedInitialState = true; // todo(anyone) store reqSrv string in a member variable and use it here // and in RequestState() @@ -302,6 +301,8 @@ void GuiRunner::OnStateQt(const msgs::SerializedStepMap &_msg) // Update all plugins this->dataPtr->updateInfo = convert(_msg.stats()); this->UpdatePlugins(); + + this->dataPtr->receivedInitialState = true; } /////////////////////////////////////////////////