mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-13 03:41:48 +00:00
Load main trace on a thread.
This commit is contained in:
parent
cd6e3ab2c9
commit
71db7c431f
@ -101,6 +101,8 @@ int main( int argc, char** argv )
|
|||||||
|
|
||||||
char addr[1024] = { "127.0.0.1" };
|
char addr[1024] = { "127.0.0.1" };
|
||||||
|
|
||||||
|
std::thread loadThread;
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
@ -122,12 +124,12 @@ int main( int argc, char** argv )
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Text( "Connect to client" );
|
ImGui::Text( "Connect to client" );
|
||||||
ImGui::InputText( "Address", addr, 1024 );
|
ImGui::InputText( "Address", addr, 1024 );
|
||||||
if( ImGui::Button( "Connect" ) && *addr )
|
if( ImGui::Button( "Connect" ) && *addr && !loadThread.joinable() )
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( addr );
|
view = std::make_unique<tracy::View>( addr );
|
||||||
}
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if( ImGui::Button( "Open saved trace" ) )
|
if( ImGui::Button( "Open saved trace" ) && !loadThread.joinable() )
|
||||||
{
|
{
|
||||||
nfdchar_t* fn;
|
nfdchar_t* fn;
|
||||||
auto res = NFD_OpenDialog( "tracy", nullptr, &fn );
|
auto res = NFD_OpenDialog( "tracy", nullptr, &fn );
|
||||||
@ -135,16 +137,21 @@ int main( int argc, char** argv )
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto f = std::unique_ptr<tracy::FileRead>( tracy::FileRead::Open( fn ) );
|
auto f = std::shared_ptr<tracy::FileRead>( tracy::FileRead::Open( fn ) );
|
||||||
if( f )
|
if( f )
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( *f );
|
loadThread = std::thread( [&view, f, &badVer] {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
view = std::make_unique<tracy::View>( *f );
|
||||||
|
}
|
||||||
|
catch( const tracy::UnsupportedVersion& e )
|
||||||
|
{
|
||||||
|
badVer = e.version;
|
||||||
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( const tracy::UnsupportedVersion& e )
|
|
||||||
{
|
|
||||||
badVer = e.version;
|
|
||||||
}
|
|
||||||
catch( const tracy::NotTracyDump& e )
|
catch( const tracy::NotTracyDump& e )
|
||||||
{
|
{
|
||||||
badVer = -1;
|
badVer = -1;
|
||||||
@ -152,12 +159,17 @@ int main( int argc, char** argv )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tracy::BadVersion( badVer );
|
if( badVer != 0 )
|
||||||
|
{
|
||||||
|
if( loadThread.joinable() ) { loadThread.join(); }
|
||||||
|
tracy::BadVersion( badVer );
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if( loadThread.joinable() ) loadThread.join();
|
||||||
if( !view->Draw() )
|
if( !view->Draw() )
|
||||||
{
|
{
|
||||||
view.reset();
|
view.reset();
|
||||||
|
Loading…
Reference in New Issue
Block a user