mirror of
https://github.com/wolfpld/tracy
synced 2025-05-01 13:13:53 +00:00
Rework processing bad files.
This commit is contained in:
parent
9b6328f962
commit
a9b41eb657
@ -102,7 +102,7 @@ int main( int argc, char** argv )
|
|||||||
tracy::flat_hash_map<uint32_t, ClientData> clients;
|
tracy::flat_hash_map<uint32_t, ClientData> clients;
|
||||||
|
|
||||||
std::unique_ptr<tracy::View> view;
|
std::unique_ptr<tracy::View> view;
|
||||||
int badVer = 0;
|
tracy::BadVersionState badVer;
|
||||||
|
|
||||||
if( argc == 2 )
|
if( argc == 2 )
|
||||||
{
|
{
|
||||||
@ -477,19 +477,20 @@ int main( int argc, char** argv )
|
|||||||
}
|
}
|
||||||
catch( const tracy::UnsupportedVersion& e )
|
catch( const tracy::UnsupportedVersion& e )
|
||||||
{
|
{
|
||||||
badVer = e.version;
|
badVer.state = tracy::BadVersionState::UnsupportedVersion;
|
||||||
|
badVer.version = e.version;
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( const tracy::NotTracyDump& )
|
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(); }
|
if( loadThread.joinable() ) { loadThread.join(); }
|
||||||
tracy::BadVersion( badVer );
|
tracy::BadVersion( badVer );
|
||||||
|
@ -10,29 +10,33 @@ namespace tracy
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
void BadVersionImpl( int& badVer )
|
void BadVersionImpl( BadVersionState& badVer )
|
||||||
{
|
{
|
||||||
assert( badVer != 0 );
|
assert( badVer.state != BadVersionState::Ok );
|
||||||
|
|
||||||
if( badVer > 0 )
|
switch( badVer.state )
|
||||||
{
|
|
||||||
ImGui::OpenPopup( "Unsupported file version" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
case BadVersionState::BadFile:
|
||||||
ImGui::OpenPopup( "Bad file" );
|
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 ) )
|
if( ImGui::BeginPopupModal( "Unsupported file version", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
||||||
{
|
{
|
||||||
#ifdef TRACY_EXTENDED_FONT
|
#ifdef TRACY_EXTENDED_FONT
|
||||||
TextCentered( ICON_FA_CLOUD_DOWNLOAD_ALT );
|
TextCentered( ICON_FA_CLOUD_DOWNLOAD_ALT );
|
||||||
#endif
|
#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();
|
ImGui::Separator();
|
||||||
if( ImGui::Button( "I understand" ) )
|
if( ImGui::Button( "I understand" ) )
|
||||||
{
|
{
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
badVer = 0;
|
badVer.state = BadVersionState::Ok;
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
@ -46,7 +50,7 @@ void BadVersionImpl( int& badVer )
|
|||||||
if( ImGui::Button( "Oops" ) )
|
if( ImGui::Button( "Oops" ) )
|
||||||
{
|
{
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
badVer = 0;
|
badVer.state = BadVersionState::Ok;
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,25 @@
|
|||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct BadVersionState
|
||||||
|
{
|
||||||
|
enum State
|
||||||
|
{
|
||||||
|
Ok,
|
||||||
|
BadFile,
|
||||||
|
UnsupportedVersion
|
||||||
|
};
|
||||||
|
|
||||||
|
State state = Ok;
|
||||||
|
int version = 0;
|
||||||
|
};
|
||||||
|
|
||||||
namespace detail
|
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 ); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7297,14 +7297,15 @@ void View::DrawCompare()
|
|||||||
}
|
}
|
||||||
catch( const tracy::UnsupportedVersion& e )
|
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& )
|
catch( const tracy::NotTracyDump& )
|
||||||
{
|
{
|
||||||
m_compare.badVer = -1;
|
m_compare.badVer.state = BadVersionState::BadFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -457,7 +457,7 @@ private:
|
|||||||
std::unique_ptr<Worker> second;
|
std::unique_ptr<Worker> second;
|
||||||
std::unique_ptr<UserData> userData;
|
std::unique_ptr<UserData> userData;
|
||||||
std::thread loadThread;
|
std::thread loadThread;
|
||||||
int badVer = 0;
|
BadVersionState badVer;
|
||||||
char pattern[1024] = {};
|
char pattern[1024] = {};
|
||||||
std::vector<int32_t> match[2];
|
std::vector<int32_t> match[2];
|
||||||
int selMatch[2] = { 0, 0 };
|
int selMatch[2] = { 0, 0 };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user