Access the user manual window through a process singleton.

The per-view and welcome-screen instances were interchangeable handles to
shared state; one instance preserves that state across view recreation.
This commit is contained in:
Bartosz Taudul
2026-10-11 21:55:26 +02:00
parent 70d00ab9f2
commit c9c1f78d59
6 changed files with 17 additions and 15 deletions

View File

@@ -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();

View File

@@ -172,7 +172,7 @@ std::string TracyLlmChat::ToolCallDescription( const nlohmann::json& json ) cons
TracyLlmChat::TracyLlmChat( View& view, Worker& worker, const std::vector<LlmSkill>& 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 )

View File

@@ -201,4 +201,10 @@ bool ManualWindow::Navigate( const char* anchor )
return true;
}
ManualWindow& GetManualWindow()
{
static ManualWindow window( GetManualData() );
return window;
}
}

View File

@@ -28,6 +28,8 @@ private:
bool& m_show;
};
ManualWindow& GetManualWindow();
}
#endif

View File

@@ -55,8 +55,7 @@ View::View( void(*cbMainThread)(const std::function<void()>&, 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<void()>&, 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 );

View File

@@ -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;