From 4fde28dad82cbd646566f9999f734115a3d9e624 Mon Sep 17 00:00:00 2001 From: Hayodea Hakol Date: Wed, 30 Jul 2025 10:07:52 -0400 Subject: [PATCH] Mrntt: Call shutdownSalmanoff after exiting main loop We moved initializeSalmanoff and shutdownSalmanoff into salmanoff.cpp. Now we also invoke shutdownSalmanoff when exiting to destroy subsystems and components gracefully. This fixes the segfault that was thrown on every program exit when xcbWindow had captured a window. --- smocore/include/marionette/marionette.h | 2 -- smocore/include/salmanoff.h | 11 +++++++++++ smocore/marionette/marionette.cpp | 3 ++- smocore/marionette/salmanoff.cpp | 10 ++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 smocore/include/salmanoff.h diff --git a/smocore/include/marionette/marionette.h b/smocore/include/marionette/marionette.h index 50b3a23..af1332c 100644 --- a/smocore/include/marionette/marionette.h +++ b/smocore/include/marionette/marionette.h @@ -28,8 +28,6 @@ struct CrtCommandLineArgs static void set(int argc, char *argv[], char *envp[]); }; -void initializeSalmanoff(void); - } // namespace smo #endif // _MARIONETTE_H diff --git a/smocore/include/salmanoff.h b/smocore/include/salmanoff.h new file mode 100644 index 0000000..703a095 --- /dev/null +++ b/smocore/include/salmanoff.h @@ -0,0 +1,11 @@ +#ifndef _SALMANOFF_H +#define _SALMANOFF_H + +namespace smo { + +void initializeSalmanoff(void); +void shutdownSalmanoff(void); + +} // namespace smo + +#endif // _SALMANOFF_H diff --git a/smocore/marionette/marionette.cpp b/smocore/marionette/marionette.cpp index d815622..39baa0c 100644 --- a/smocore/marionette/marionette.cpp +++ b/smocore/marionette/marionette.cpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace smo { @@ -104,6 +105,7 @@ void ComponentThread::marionetteMain(ComponentThread& self) } std::cout << __func__ << ": Exited event loop" << "\n"; + shutdownSalmanoff(); } catch (const std::exception& e) { @@ -122,5 +124,4 @@ void ComponentThread::marionetteMain(ComponentThread& self) std::cout << __func__ << ": Exiting normally" << std::endl; } - } // namespace smo diff --git a/smocore/marionette/salmanoff.cpp b/smocore/marionette/salmanoff.cpp index 1434c83..1e951a2 100644 --- a/smocore/marionette/salmanoff.cpp +++ b/smocore/marionette/salmanoff.cpp @@ -23,4 +23,14 @@ std::cerr << "Done attachAllSenseDevicesFromSpecs" << std::endl; std::cout << __func__ << ": Done." << std::endl; } +void shutdownSalmanoff(void) +{ + std::cout << __func__ << ": Entered." << std::endl; + + sense_api::SenseApiManager::getInstance().detachAllSenseDevices(); + sense_api::SenseApiManager::getInstance().finalizeAllSenseApiLibs(); + + std::cout << __func__ << ": Done." << std::endl; +} + } // namespace smo