Handle load failure exceptions.

This commit is contained in:
Bartosz Taudul 2023-12-31 14:16:06 +01:00
parent 5062bef69a
commit b262cb2428
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 24 additions and 0 deletions

View File

@ -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;
}
} );
}
}

View File

@ -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();
}
}
}