1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 04:23:51 +00:00

Rework processing bad files.

This commit is contained in:
Bartosz Taudul 2019-08-12 12:04:27 +02:00
parent 9b6328f962
commit a9b41eb657
5 changed files with 38 additions and 19 deletions

View File

@ -102,7 +102,7 @@ int main( int argc, char** argv )
tracy::flat_hash_map<uint32_t, ClientData> clients;
std::unique_ptr<tracy::View> view;
int badVer = 0;
tracy::BadVersionState badVer;
if( argc == 2 )
{
@ -477,19 +477,20 @@ int main( int argc, char** argv )
}
catch( const tracy::UnsupportedVersion& e )
{
badVer = e.version;
badVer.state = tracy::BadVersionState::UnsupportedVersion;
badVer.version = e.version;
}
} );
}
}
catch( const tracy::NotTracyDump& )
{
badVer = -1;
badVer.state = tracy::BadVersionState::BadFile;
}
}
}
if( badVer != 0 )
if( badVer.state != tracy::BadVersionState::Ok )
{
if( loadThread.joinable() ) { loadThread.join(); }
tracy::BadVersion( badVer );

View File

@ -10,29 +10,33 @@ namespace tracy
namespace detail
{
void BadVersionImpl( int& badVer )
void BadVersionImpl( BadVersionState& badVer )
{
assert( badVer != 0 );
assert( badVer.state != BadVersionState::Ok );
if( badVer > 0 )
{
ImGui::OpenPopup( "Unsupported file version" );
}
else
switch( badVer.state )
{
case BadVersionState::BadFile:
ImGui::OpenPopup( "Bad file" );
break;
case BadVersionState::UnsupportedVersion:
ImGui::OpenPopup( "Unsupported 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 >> 16, ( badVer >> 8 ) & 0xFF, badVer & 0xFF );
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 = 0;
badVer.state = BadVersionState::Ok;
}
ImGui::EndPopup();
}
@ -46,7 +50,7 @@ void BadVersionImpl( int& badVer )
if( ImGui::Button( "Oops" ) )
{
ImGui::CloseCurrentPopup();
badVer = 0;
badVer.state = BadVersionState::Ok;
}
ImGui::EndPopup();
}

View File

@ -6,12 +6,25 @@
namespace tracy
{
struct BadVersionState
{
enum State
{
Ok,
BadFile,
UnsupportedVersion
};
State state = Ok;
int version = 0;
};
namespace detail
{
void BadVersionImpl( int& badVer );
void BadVersionImpl( BadVersionState& badVer );
}
tracy_force_inline void BadVersion( int& badVer ) { if( badVer != 0 ) detail::BadVersionImpl( badVer ); }
tracy_force_inline void BadVersion( BadVersionState& badVer ) { if( badVer.state != BadVersionState::Ok ) detail::BadVersionImpl( badVer ); }
}

View File

@ -7297,14 +7297,15 @@ void View::DrawCompare()
}
catch( const tracy::UnsupportedVersion& e )
{
m_compare.badVer = e.version;
m_compare.badVer.state = BadVersionState::UnsupportedVersion;
m_compare.badVer.version = e.version;
}
} );
}
}
catch( const tracy::NotTracyDump& )
{
m_compare.badVer = -1;
m_compare.badVer.state = BadVersionState::BadFile;
}
}
}

View File

@ -457,7 +457,7 @@ private:
std::unique_ptr<Worker> second;
std::unique_ptr<UserData> userData;
std::thread loadThread;
int badVer = 0;
BadVersionState badVer;
char pattern[1024] = {};
std::vector<int32_t> match[2];
int selMatch[2] = { 0, 0 };