From 06845023d1c7946ab3681b87dec9468d274e8488 Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Sat, 1 Apr 2023 10:56:44 -0300 Subject: [PATCH] core: prevent static initialization issue with Time::Resolution on Cppyy 3 --- src/core/model/nstime.h | 6 +++--- src/core/model/time.cc | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/model/nstime.h b/src/core/model/nstime.h index 294895f7f..59e47c457 100644 --- a/src/core/model/nstime.h +++ b/src/core/model/nstime.h @@ -653,8 +653,7 @@ class Time */ static inline Resolution* PeekResolution() { - static Time::Resolution& resolution{SetDefaultNsResolution()}; - return &resolution; + return &m_resolution; } /** @@ -832,7 +831,8 @@ class Time friend Time& operator-=(Time& lhs, const Time& rhs); /**@}*/ // Compound assignment - int64_t m_data; //!< Virtual time value, in the current unit. + int64_t m_data; //!< Virtual time value, in the current unit. + static Time::Resolution m_resolution; //!< The current time resolution }; // class Time diff --git a/src/core/model/time.cc b/src/core/model/time.cc index 32a0f9446..4d93ad8d3 100644 --- a/src/core/model/time.cc +++ b/src/core/model/time.cc @@ -91,6 +91,9 @@ Time::MarkedTimes* Time::g_markingTimes = nullptr; /// The static mutex for critical sections around modification of Time::g_markingTimes. static std::mutex g_markingMutex; +// The resolution of the Time class +Time::Resolution Time::m_resolution{SetDefaultNsResolution()}; + // Function called to force static initialization // static bool