Store trace file path in UserData.

This commit is contained in:
Bartosz Taudul
2026-06-05 17:32:46 +02:00
parent fc97af4c68
commit e95a757e6c
4 changed files with 18 additions and 7 deletions

View File

@@ -25,12 +25,13 @@ UserData::UserData()
{ {
} }
UserData::UserData( const char* program, uint64_t time ) UserData::UserData( const char* program, uint64_t time, const char* filePath )
: m_program( program ) : m_program( program )
, m_time( time ) , m_time( time )
, m_preserveState( false ) , m_preserveState( false )
{ {
if( m_program.empty() ) m_program = "_"; if( m_program.empty() ) m_program = "_";
if( filePath ) m_filePath = filePath;
if( !Load() ) if( !Load() )
{ {
@@ -41,15 +42,22 @@ UserData::UserData( const char* program, uint64_t time )
} }
} }
void UserData::Init( const char* program, uint64_t time ) void UserData::Init( const char* program, uint64_t time, const char* filePath )
{ {
assert( !Valid() ); assert( !Valid() );
m_program = program; m_program = program;
m_time = time; m_time = time;
if( filePath ) m_filePath = filePath;
if( m_program.empty() ) m_program = "_"; if( m_program.empty() ) m_program = "_";
} }
void UserData::SetFilePath( const char* filePath )
{
assert( filePath );
m_filePath = filePath;
}
void UserData::SetDescription( const char* description ) void UserData::SetDescription( const char* description )
{ {
m_description = description; m_description = description;

View File

@@ -20,10 +20,11 @@ class UserData
{ {
public: public:
UserData(); UserData();
UserData( const char* program, uint64_t time ); UserData( const char* program, uint64_t time, const char* filePath );
bool Valid() const { return !m_program.empty(); } bool Valid() const { return !m_program.empty(); }
void Init( const char* program, uint64_t time ); void Init( const char* program, uint64_t time, const char* filePath );
void SetFilePath( const char* filePath );
const std::string& GetDescription() const { return m_description; } const std::string& GetDescription() const { return m_description; }
void SetDescription( const char* description ); void SetDescription( const char* description );
@@ -55,6 +56,7 @@ private:
std::string m_program; std::string m_program;
uint64_t m_time; uint64_t m_time;
std::string m_filePath;
std::string m_description; std::string m_description;
ViewData m_viewData; ViewData m_viewData;

View File

@@ -78,7 +78,7 @@ View::View( void(*cbMainThread)(const std::function<void()>&, bool), FileRead& f
, m_stcb( stcb ) , m_stcb( stcb )
, m_sscb( sscb ) , m_sscb( sscb )
, m_acb( acb ) , m_acb( acb )
, m_userData( m_worker.GetCaptureProgram().c_str(), m_worker.GetCaptureTime() ) , m_userData( m_worker.GetCaptureProgram().c_str(), m_worker.GetCaptureTime(), f.GetFilename().c_str() )
, m_cbMainThread( cbMainThread ) , m_cbMainThread( cbMainThread )
, m_achievementsMgr( amgr ) , m_achievementsMgr( amgr )
, m_achievements( s_config.achievements ) , m_achievements( s_config.achievements )
@@ -738,7 +738,7 @@ bool View::DrawImpl()
m_uarchSet = true; m_uarchSet = true;
m_sourceView->SetCpuId( m_worker.GetCpuId() ); m_sourceView->SetCpuId( m_worker.GetCpuId() );
} }
if( !m_userData.Valid() ) m_userData.Init( m_worker.GetCaptureProgram().c_str(), m_worker.GetCaptureTime() ); if( !m_userData.Valid() ) m_userData.Init( m_worker.GetCaptureProgram().c_str(), m_worker.GetCaptureTime(), nullptr );
if( m_saveThreadState.load( std::memory_order_acquire ) == SaveThreadState::NeedsJoin ) if( m_saveThreadState.load( std::memory_order_acquire ) == SaveThreadState::NeedsJoin )
{ {
m_saveThread.join(); m_saveThread.join();
@@ -1476,6 +1476,7 @@ bool View::Save( const char* fn, FileCompression comp, int zlevel, bool buildDic
if( !f ) return false; if( !f ) return false;
m_userData.StateShouldBePreserved(); m_userData.StateShouldBePreserved();
m_userData.SetFilePath( fn );
m_saveThreadState.store( SaveThreadState::Saving, std::memory_order_relaxed ); m_saveThreadState.store( SaveThreadState::Saving, std::memory_order_relaxed );
m_saveThread = std::thread( [this, f{std::move( f )}, buildDict] { m_saveThread = std::thread( [this, f{std::move( f )}, buildDict] {
Worker::MainThreadDataLockGuard lock = m_worker.ObtainLockForMainThread(); Worker::MainThreadDataLockGuard lock = m_worker.ObtainLockForMainThread();

View File

@@ -226,7 +226,7 @@ void View::DrawCompare()
try try
{ {
m_compare.second = std::make_unique<Worker>( *f, EventType::SourceCache ); m_compare.second = std::make_unique<Worker>( *f, EventType::SourceCache );
m_compare.userData = std::make_unique<UserData>( m_compare.second->GetCaptureProgram().c_str(), m_compare.second->GetCaptureTime() ); m_compare.userData = std::make_unique<UserData>( m_compare.second->GetCaptureProgram().c_str(), m_compare.second->GetCaptureTime(), nullptr );
m_compare.diffDirection = m_worker.GetCaptureTime() < m_compare.second->GetCaptureTime(); m_compare.diffDirection = m_worker.GetCaptureTime() < m_compare.second->GetCaptureTime();
} }
catch( const tracy::UnsupportedVersion& e ) catch( const tracy::UnsupportedVersion& e )