Handle FileReadError.

This commit is contained in:
Bartosz Taudul 2020-02-12 19:53:37 +01:00
parent eb79507501
commit 1492536bdb
5 changed files with 31 additions and 0 deletions

View File

@ -581,6 +581,10 @@ static void DrawContents()
{ {
badVer.state = tracy::BadVersionState::BadFile; badVer.state = tracy::BadVersionState::BadFile;
} }
catch( const tracy::FileReadError& )
{
badVer.state = tracy::BadVersionState::ReadError;
}
} }
} }

View File

@ -19,6 +19,9 @@ void BadVersionImpl( BadVersionState& badVer )
case BadVersionState::BadFile: case BadVersionState::BadFile:
ImGui::OpenPopup( "Bad file" ); ImGui::OpenPopup( "Bad file" );
break; break;
case BadVersionState::ReadError:
ImGui::OpenPopup( "File read error" );
break;
case BadVersionState::UnsupportedVersion: case BadVersionState::UnsupportedVersion:
ImGui::OpenPopup( "Unsupported file version" ); ImGui::OpenPopup( "Unsupported file version" );
break; break;
@ -43,6 +46,20 @@ void BadVersionImpl( BadVersionState& badVer )
} }
ImGui::EndPopup(); ImGui::EndPopup();
} }
if( ImGui::BeginPopupModal( "File read error", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
{
#ifdef TRACY_EXTENDED_FONT
TextCentered( ICON_FA_EXCLAMATION_TRIANGLE );
#endif
ImGui::Text( "The file you are trying to open cannot be mapped to memory." );
ImGui::Separator();
if( ImGui::Button( "OK" ) )
{
ImGui::CloseCurrentPopup();
badVer.state = BadVersionState::Ok;
}
ImGui::EndPopup();
}
if( ImGui::BeginPopupModal( "Unsupported file version", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) if( ImGui::BeginPopupModal( "Unsupported file version", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
{ {
#ifdef TRACY_EXTENDED_FONT #ifdef TRACY_EXTENDED_FONT

View File

@ -12,6 +12,7 @@ struct BadVersionState
{ {
Ok, Ok,
BadFile, BadFile,
ReadError,
UnsupportedVersion, UnsupportedVersion,
LegacyVersion LegacyVersion
}; };

View File

@ -9768,6 +9768,10 @@ void View::DrawCompare()
{ {
m_compare.badVer.state = BadVersionState::BadFile; m_compare.badVer.state = BadVersionState::BadFile;
} }
catch( const tracy::FileReadError& )
{
m_compare.badVer.state = BadVersionState::ReadError;
}
} }
} }
tracy::BadVersion( m_compare.badVer ); tracy::BadVersion( m_compare.badVer );

View File

@ -139,6 +139,11 @@ int main( int argc, char** argv )
fprintf( stderr, "The file you are trying to open is not a tracy dump.\n" ); fprintf( stderr, "The file you are trying to open is not a tracy dump.\n" );
exit( 1 ); exit( 1 );
} }
catch( const tracy::FileReadError& e )
{
fprintf( stderr, "The file you are trying to open cannot be mapped to memory.\n" );
exit( 1 );
}
catch( const tracy::LegacyVersion& e ) catch( const tracy::LegacyVersion& e )
{ {
fprintf( stderr, "The file you are trying to open is from a legacy version.\n" ); fprintf( stderr, "The file you are trying to open is from a legacy version.\n" );