diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index d25f08fd..6b3833a9 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -597,8 +597,7 @@ static void DrawContents() static std::string reconnectAddr; static uint16_t reconnectPort; static bool showFilter = false; - static tracy::ManualWindow s_manualWindow( tracy::GetManualData() ); - static tracy::Markdown s_manualMarkdown( nullptr, nullptr, &s_manualWindow ); + static tracy::Markdown s_manualMarkdown( nullptr, nullptr, &tracy::GetManualWindow() ); #ifndef __EMSCRIPTEN__ UpdateBroadcastClients(); @@ -834,7 +833,7 @@ static void DrawContents() ImGui::Spacing(); if( ImGui::Button( ICON_FA_BOOK " Manual" ) ) { - s_manualWindow.Show() = true; + tracy::GetManualWindow().Show() = true; } ImGui::SameLine(); if( ImGui::Button( ICON_FA_EARTH_AMERICAS " Web" ) ) @@ -1585,10 +1584,10 @@ Would you like to enable achievements? } } - if( s_manualWindow.Show() ) + if( tracy::GetManualWindow().Show() ) { if( tracy::s_config.achievements ) s_achievements->Achieve( "manual" ); - if( !viewPtr ) s_manualWindow.Draw( s_manualMarkdown ); + if( !viewPtr ) tracy::GetManualWindow().Draw( s_manualMarkdown ); } bptr->EndFrame(); diff --git a/profiler/src/profiler/TracyLlmChat.cpp b/profiler/src/profiler/TracyLlmChat.cpp index 5ed62dcf..d8ae39d6 100644 --- a/profiler/src/profiler/TracyLlmChat.cpp +++ b/profiler/src/profiler/TracyLlmChat.cpp @@ -172,7 +172,7 @@ std::string TracyLlmChat::ToolCallDescription( const nlohmann::json& json ) cons TracyLlmChat::TracyLlmChat( View& view, Worker& worker, const std::vector& skills ) : m_width( new float[NumRoles] ) - , m_markdown( &view, &worker, &view.GetManualWindow() ) + , m_markdown( &view, &worker, &GetManualWindow() ) , m_skills( skills ) , m_worker( worker ) , m_view( view ) diff --git a/profiler/src/profiler/TracyManualWindow.cpp b/profiler/src/profiler/TracyManualWindow.cpp index e163a38a..b09ff601 100644 --- a/profiler/src/profiler/TracyManualWindow.cpp +++ b/profiler/src/profiler/TracyManualWindow.cpp @@ -201,4 +201,10 @@ bool ManualWindow::Navigate( const char* anchor ) return true; } +ManualWindow& GetManualWindow() +{ + static ManualWindow window( GetManualData() ); + return window; +} + } diff --git a/profiler/src/profiler/TracyManualWindow.hpp b/profiler/src/profiler/TracyManualWindow.hpp index ef79f871..b8c57c6f 100644 --- a/profiler/src/profiler/TracyManualWindow.hpp +++ b/profiler/src/profiler/TracyManualWindow.hpp @@ -28,6 +28,8 @@ private: bool& m_show; }; +ManualWindow& GetManualWindow(); + } #endif diff --git a/profiler/src/profiler/TracyView.cpp b/profiler/src/profiler/TracyView.cpp index 06f9fbbb..cd787cd7 100644 --- a/profiler/src/profiler/TracyView.cpp +++ b/profiler/src/profiler/TracyView.cpp @@ -55,8 +55,7 @@ View::View( void(*cbMainThread)(const std::function&, bool), const char* , m_horizontalScrollMultiplier( s_config.horizontalScrollMultiplier ) , m_verticalScrollMultiplier( s_config.verticalScrollMultiplier ) , m_manualData( GetManualData() ) - , m_manualWindow( m_manualData ) - , m_markdown( this, &m_worker, &m_manualWindow ) + , m_markdown( this, &m_worker, &GetManualWindow() ) #ifdef __EMSCRIPTEN__ , m_td( 2, "ViewMt" ) #else @@ -88,8 +87,7 @@ View::View( void(*cbMainThread)(const std::function&, bool), FileRead& f , m_horizontalScrollMultiplier( s_config.horizontalScrollMultiplier ) , m_verticalScrollMultiplier( s_config.verticalScrollMultiplier ) , m_manualData( GetManualData() ) - , m_manualWindow( m_manualData ) - , m_markdown( this, &m_worker, &m_manualWindow ) + , m_markdown( this, &m_worker, &GetManualWindow() ) #ifdef __EMSCRIPTEN__ , m_td( 2, "ViewMt" ) #else @@ -1019,7 +1017,7 @@ bool View::DrawImpl() ImGui::EndPopup(); } ImGui::SameLine(); - ToggleButton( ICON_FA_BOOK, m_manualWindow.Show() ); + ToggleButton( ICON_FA_BOOK, GetManualWindow().Show() ); if( m_sscb ) { ImGui::SameLine(); @@ -1236,7 +1234,7 @@ bool View::DrawImpl() if( m_sampleParents.symAddr != 0 ) DrawSampleParents(); if( m_showRanges ) DrawRanges(); if( m_showWaitStacks ) DrawWaitStacks(); - if( m_manualWindow.Show() ) m_manualWindow.Draw( m_markdown ); + if( GetManualWindow().Show() ) GetManualWindow().Draw( m_markdown ); if( m_showFrameStatistics ) DrawFrameStatistics(); #ifndef __EMSCRIPTEN__ if( m_llm.m_show ) m_llm.Draw( m_llmConstraint ); diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index c68ec688..68e06471 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -168,8 +168,6 @@ public: void ViewSymbol( const char* fileName, int line, uint64_t baseAddr, uint64_t symAddr ); bool ViewDispatch( const char* fileName, int line, uint64_t symAddr ); - ManualWindow& GetManualWindow() { return m_manualWindow; } - bool ReconnectRequested() const { return m_reconnectRequested; } std::string GetAddress() const { return m_worker.GetAddr(); } uint16_t GetPort() const { return m_worker.GetPort(); } @@ -1081,7 +1079,6 @@ private: double m_verticalScrollMultiplier = 1.0; const TracyManualData& m_manualData; - ManualWindow m_manualWindow; Markdown m_markdown; TaskDispatch m_td;