From 4c521ce92ae70afa03d58e08ae5b7e96b6be0f47 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 30 Apr 2018 01:16:08 +0200 Subject: [PATCH] Loaded traces may be unloaded. --- server/TracyView.cpp | 28 ++++++++++++++++++---------- server/TracyView.hpp | 4 ++-- standalone/src/main.cpp | 5 ++++- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 563d2dcd..ac769bf0 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -278,9 +278,9 @@ void View::DrawTextContrast( ImDrawList* draw, const ImVec2& pos, uint32_t color draw->AddText( pos, color, text ); } -void View::Draw() +bool View::Draw() { - s_instance->DrawImpl(); + return s_instance->DrawImpl(); } static const char* MainWindowButtons[] = { @@ -290,19 +290,14 @@ static const char* MainWindowButtons[] = { enum { MainWindowButtonsCount = sizeof( MainWindowButtons ) / sizeof( *MainWindowButtons ) }; -void View::DrawImpl() +bool View::DrawImpl() { if( !m_worker.HasData() ) { ImGui::Begin( m_worker.GetAddr().c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize ); ImGui::Text( "Waiting for connection..." ); ImGui::End(); - return; - } - - if( !m_staticView ) - { - DrawConnection(); + return true; } const auto th = ImGui::GetTextLineHeight(); @@ -313,8 +308,19 @@ void View::DrawImpl() } bw += th; + bool keepOpen = true; + bool* keepOpenPtr = nullptr; + if( !m_staticView ) + { + DrawConnection(); + } + else + { + keepOpenPtr = &keepOpen; + } + std::lock_guard lock( m_worker.GetDataLock() ); - ImGui::Begin( m_worker.GetCaptureName().c_str(), nullptr, ImVec2( 1550, 800 ), -1, ImGuiWindowFlags_NoScrollbar ); + ImGui::Begin( m_worker.GetCaptureName().c_str(), keepOpenPtr, ImVec2( 1550, 800 ), -1, ImGuiWindowFlags_NoScrollbar ); if( !m_worker.IsDataStatic() ) { if( ImGui::Button( m_pause ? MainWindowButtons[0] : MainWindowButtons[1], ImVec2( bw, 0 ) ) ) m_pause = !m_pause; @@ -366,6 +372,8 @@ void View::DrawImpl() m_zvEnd = int64_t( m_zoomAnim.end0 + ( m_zoomAnim.end1 - m_zoomAnim.end0 ) * v ); } } + + return keepOpen; } void View::DrawConnection() diff --git a/server/TracyView.hpp b/server/TracyView.hpp index e363b84a..099235f3 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -45,7 +45,7 @@ public: View( FileRead& f ); ~View(); - static void Draw(); + static bool Draw(); private: enum class Namespace : uint8_t @@ -61,7 +61,7 @@ private: void DrawTextContrast( ImDrawList* draw, const ImVec2& pos, uint32_t color, const char* text ); - void DrawImpl(); + bool DrawImpl(); void DrawConnection(); void DrawFrames(); bool DrawZoneFrames(); diff --git a/standalone/src/main.cpp b/standalone/src/main.cpp index 7fe494fe..92cf0989 100644 --- a/standalone/src/main.cpp +++ b/standalone/src/main.cpp @@ -127,7 +127,10 @@ int main( int argc, char** argv ) } else { - view->Draw(); + if( !view->Draw() ) + { + view.reset(); + } } // Rendering