From dc5444ff0f0e098e6b5b4f8b134fe6c925533c3b Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 28 Aug 2019 19:37:01 +0200 Subject: [PATCH] Notify UserData that view state should be preserved. This is only active when a trace is loaded from a file (and state should be persistent for future sessions using this trace), or when state is saved to a file (so that future sessions will use current state). No state is preserved by default, i.e. when the trace was not saved to a file. --- server/TracyUserData.cpp | 6 ++++++ server/TracyUserData.hpp | 4 ++++ server/TracyView.cpp | 2 ++ 3 files changed, 12 insertions(+) diff --git a/server/TracyUserData.cpp b/server/TracyUserData.cpp index 670b29c8..86eff760 100644 --- a/server/TracyUserData.cpp +++ b/server/TracyUserData.cpp @@ -10,6 +10,7 @@ namespace tracy constexpr auto FileDescription = "description"; UserData::UserData() + : m_preserveState( false ) { } @@ -52,6 +53,11 @@ bool UserData::SetDescription( const char* description ) return true; } +void UserData::StateShouldBePreserved() +{ + m_preserveState = true; +} + FILE* UserData::OpenFile( const char* filename, bool write ) { const auto path = GetSavePath( m_program.c_str(), m_time, filename, write ); diff --git a/server/TracyUserData.hpp b/server/TracyUserData.hpp index 6db8bd4f..3bc07943 100644 --- a/server/TracyUserData.hpp +++ b/server/TracyUserData.hpp @@ -20,6 +20,8 @@ public: const std::string& GetDescription() const { return m_description; } bool SetDescription( const char* description ); + void StateShouldBePreserved(); + private: FILE* OpenFile( const char* filename, bool write ); @@ -27,6 +29,8 @@ private: uint64_t m_time; std::string m_description; + + bool m_preserveState; }; } diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 02e0a064..c0b9fa77 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -148,6 +148,7 @@ View::View( FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, InitTextEditor(); SetViewToLastFrames(); + m_userData.StateShouldBePreserved(); } View::~View() @@ -852,6 +853,7 @@ bool View::DrawConnection() } if( f ) { + m_userData.StateShouldBePreserved(); m_saveThreadState.store( SaveThreadState::Saving, std::memory_order_relaxed ); m_saveThread = std::thread( [this, f{std::move( f )}] { std::shared_lock lock( m_worker.GetDataLock() );