From fefcbc6c3530a2a1e9317b1a09caff00d62e5f05 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 21 Apr 2018 14:31:33 +0200 Subject: [PATCH] Handle opening unsupported files. --- standalone/src/main.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/standalone/src/main.cpp b/standalone/src/main.cpp index 8d197ff8..7d49993a 100644 --- a/standalone/src/main.cpp +++ b/standalone/src/main.cpp @@ -18,6 +18,7 @@ static void glfw_error_callback(int error, const char* description) int main( int argc, char** argv ) { std::unique_ptr view; + int badVer = 0; if( argc == 2 ) { @@ -103,10 +104,31 @@ int main( int argc, char** argv ) auto f = std::unique_ptr( tracy::FileRead::Open( fn ) ); if( f ) { - view = std::make_unique( *f ); + try + { + view = std::make_unique( *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(); } else