Handle legacy file versions.

This commit is contained in:
Bartosz Taudul 2019-08-12 12:16:48 +02:00
parent 54076e717c
commit 154c902e03
5 changed files with 49 additions and 15 deletions

View File

@ -480,6 +480,11 @@ int main( int argc, char** argv )
badVer.state = tracy::BadVersionState::UnsupportedVersion;
badVer.version = e.version;
}
catch( const tracy::LegacyVersion& e )
{
badVer.state = tracy::BadVersionState::LegacyVersion;
badVer.version = e.version;
}
} );
}
}

View File

@ -22,24 +22,13 @@ void BadVersionImpl( BadVersionState& badVer )
case BadVersionState::UnsupportedVersion:
ImGui::OpenPopup( "Unsupported file version" );
break;
case BadVersionState::LegacyVersion:
ImGui::OpenPopup( "Legacy file version" );
break;
default:
assert( false );
break;
}
if( ImGui::BeginPopupModal( "Unsupported file version", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
{
#ifdef TRACY_EXTENDED_FONT
TextCentered( ICON_FA_CLOUD_DOWNLOAD_ALT );
#endif
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.version >> 16, ( badVer.version >> 8 ) & 0xFF, badVer.version & 0xFF );
ImGui::Separator();
if( ImGui::Button( "I understand" ) )
{
ImGui::CloseCurrentPopup();
badVer.state = BadVersionState::Ok;
}
ImGui::EndPopup();
}
if( ImGui::BeginPopupModal( "Bad file", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
{
#ifdef TRACY_EXTENDED_FONT
@ -54,6 +43,34 @@ void BadVersionImpl( BadVersionState& badVer )
}
ImGui::EndPopup();
}
if( ImGui::BeginPopupModal( "Unsupported file version", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
{
#ifdef TRACY_EXTENDED_FONT
TextCentered( ICON_FA_CLOUD_DOWNLOAD_ALT );
#endif
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.version >> 16, ( badVer.version >> 8 ) & 0xFF, badVer.version & 0xFF );
ImGui::Separator();
if( ImGui::Button( "I understand" ) )
{
ImGui::CloseCurrentPopup();
badVer.state = BadVersionState::Ok;
}
ImGui::EndPopup();
}
if( ImGui::BeginPopupModal( "Legacy file version", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
{
#ifdef TRACY_EXTENDED_FONT
TextCentered( ICON_FA_GHOST );
#endif
ImGui::Text( "You are trying to open a file which was created by legacy version %i.%i.%i.\nUse the update utility from an older version of the profiler to convert the file to a supported version.", badVer.version >> 16, ( badVer.version >> 8 ) & 0xFF, badVer.version & 0xFF );
ImGui::Separator();
if( ImGui::Button( "Maybe I don't need it" ) )
{
ImGui::CloseCurrentPopup();
badVer.state = BadVersionState::Ok;
}
ImGui::EndPopup();
}
}
}

View File

@ -12,7 +12,8 @@ struct BadVersionState
{
Ok,
BadFile,
UnsupportedVersion
UnsupportedVersion,
LegacyVersion
};
State state = Ok;

View File

@ -47,6 +47,12 @@ struct UnsupportedVersion : public std::exception
int version;
};
struct LegacyVersion : public std::exception
{
LegacyVersion( int version ) : version ( version ) {}
int version;
};
struct LoadProgress
{
enum Stage

View File

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