mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Display a dialog when user tries to open invalid file.
This commit is contained in:
parent
764792d8db
commit
3b6b67b7ee
@ -101,22 +101,36 @@ int main( int argc, char** argv )
|
|||||||
auto res = NFD_OpenDialog( "tracy", nullptr, &fn );
|
auto res = NFD_OpenDialog( "tracy", nullptr, &fn );
|
||||||
if( res == NFD_OKAY )
|
if( res == NFD_OKAY )
|
||||||
{
|
{
|
||||||
auto f = std::unique_ptr<tracy::FileRead>( tracy::FileRead::Open( fn ) );
|
try
|
||||||
if( f )
|
|
||||||
{
|
{
|
||||||
try
|
auto f = std::unique_ptr<tracy::FileRead>( tracy::FileRead::Open( fn ) );
|
||||||
|
if( f )
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( *f );
|
view = std::make_unique<tracy::View>( *f );
|
||||||
}
|
}
|
||||||
catch( const tracy::UnsupportedVersion& e )
|
}
|
||||||
{
|
catch( const tracy::UnsupportedVersion& e )
|
||||||
badVer = e.version;
|
{
|
||||||
}
|
badVer = e.version;
|
||||||
|
}
|
||||||
|
catch( const tracy::NotTracyDump& e )
|
||||||
|
{
|
||||||
|
badVer = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( badVer != 0 ) ImGui::OpenPopup( "Unsupported file version" );
|
if( badVer != 0 )
|
||||||
|
{
|
||||||
|
if( badVer > 0 )
|
||||||
|
{
|
||||||
|
ImGui::OpenPopup( "Unsupported file version" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui::OpenPopup( "Bad file" );
|
||||||
|
}
|
||||||
|
}
|
||||||
if( ImGui::BeginPopupModal( "Unsupported file version", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
if( ImGui::BeginPopupModal( "Unsupported file version", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
||||||
{
|
{
|
||||||
ImGui::Text( "The file you are trying to open is unsupported.\nYou should update to tracy %i.%i.%i or newer and try again.", badVer >> 16, ( badVer >> 8 ) & 0xFF, badVer & 0xFF );
|
ImGui::Text( "The file you are trying to open is unsupported.\nYou should update to tracy %i.%i.%i or newer and try again.", badVer >> 16, ( badVer >> 8 ) & 0xFF, badVer & 0xFF );
|
||||||
@ -128,6 +142,17 @@ int main( int argc, char** argv )
|
|||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
if( ImGui::BeginPopupModal( "Bad file", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
||||||
|
{
|
||||||
|
ImGui::Text( "The file you are trying to open is not a tracy dump." );
|
||||||
|
ImGui::Separator();
|
||||||
|
if( ImGui::Button( "Oops" ) )
|
||||||
|
{
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
badVer = 0;
|
||||||
|
}
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user