Handle opening unsupported files.

This commit is contained in:
Bartosz Taudul 2018-04-21 14:31:33 +02:00
parent 36efe96e9d
commit fefcbc6c35

View File

@ -18,6 +18,7 @@ static void glfw_error_callback(int error, const char* description)
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
std::unique_ptr<tracy::View> view; std::unique_ptr<tracy::View> view;
int badVer = 0;
if( argc == 2 ) if( argc == 2 )
{ {
@ -102,11 +103,32 @@ int main( int argc, char** argv )
{ {
auto f = std::unique_ptr<tracy::FileRead>( tracy::FileRead::Open( fn ) ); auto f = std::unique_ptr<tracy::FileRead>( tracy::FileRead::Open( fn ) );
if( f ) if( f )
{
try
{ {
view = std::make_unique<tracy::View>( *f ); view = std::make_unique<tracy::View>( *f );
} }
catch( const tracy::UnsupportedVersion& e )
{
badVer = e.version;
} }
} }
}
}
if( badVer != 0 ) ImGui::OpenPopup( "Unsupported file version" );
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::Separator();
if( ImGui::Button( "I understand" ) )
{
ImGui::CloseCurrentPopup();
badVer = 0;
}
ImGui::EndPopup();
}
ImGui::End(); ImGui::End();
} }
else else