From b262cb2428bc68dfd0aa9ae98297fcf2b29bdacb Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 31 Dec 2023 14:16:06 +0100 Subject: [PATCH] Handle load failure exceptions. --- profiler/src/main.cpp | 5 +++++ server/TracyBadVersion.cpp | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index dd2ca5ce..34f7f087 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -766,6 +766,11 @@ static void DrawContents() badVer.state = tracy::BadVersionState::LegacyVersion; badVer.version = e.version; } + catch( const tracy::LoadFailure& e ) + { + badVer.state = tracy::BadVersionState::LoadFailure; + badVer.msg = e.msg; + } } ); } } diff --git a/server/TracyBadVersion.cpp b/server/TracyBadVersion.cpp index 9415f1e8..91560553 100644 --- a/server/TracyBadVersion.cpp +++ b/server/TracyBadVersion.cpp @@ -31,6 +31,9 @@ void BadVersionImpl( BadVersionState& badVer, ImFont* big ) case BadVersionState::LegacyVersion: ImGui::OpenPopup( "Legacy file version" ); break; + case BadVersionState::LoadFailure: + ImGui::OpenPopup( "Trace load failure" ); + break; default: assert( false ); break; @@ -98,6 +101,22 @@ void BadVersionImpl( BadVersionState& badVer, ImFont* big ) } ImGui::EndPopup(); } + if( ImGui::BeginPopupModal( "Trace load failure", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) + { + ImGui::PushFont( big ); + TextCentered( ICON_FA_BOMB ); + ImGui::PopFont(); + ImGui::TextUnformatted( "The file you are trying to open is corrupted." ); + ImGui::Spacing(); + ImGui::TextUnformatted( badVer.msg.c_str() ); + ImGui::Separator(); + if( ImGui::Button( "OK" ) ) + { + ImGui::CloseCurrentPopup(); + badVer.state = BadVersionState::Ok; + } + ImGui::EndPopup(); + } } }