Loaded traces may be unloaded.

This commit is contained in:
Bartosz Taudul 2018-04-30 01:16:08 +02:00
parent e5cb241c19
commit 4c521ce92a
3 changed files with 24 additions and 13 deletions

View File

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

View File

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

View File

@ -127,7 +127,10 @@ int main( int argc, char** argv )
}
else
{
view->Draw();
if( !view->Draw() )
{
view.reset();
}
}
// Rendering