mirror of
https://github.com/wolfpld/tracy.git
synced 2026-06-08 08:33:48 +00:00
Store trace file path in UserData.
This commit is contained in:
@@ -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_time( time )
|
||||
, m_preserveState( false )
|
||||
{
|
||||
if( m_program.empty() ) m_program = "_";
|
||||
if( filePath ) m_filePath = filePath;
|
||||
|
||||
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() );
|
||||
m_program = program;
|
||||
m_time = time;
|
||||
if( filePath ) m_filePath = filePath;
|
||||
|
||||
if( m_program.empty() ) m_program = "_";
|
||||
}
|
||||
|
||||
void UserData::SetFilePath( const char* filePath )
|
||||
{
|
||||
assert( filePath );
|
||||
m_filePath = filePath;
|
||||
}
|
||||
|
||||
void UserData::SetDescription( const char* description )
|
||||
{
|
||||
m_description = description;
|
||||
|
||||
@@ -20,10 +20,11 @@ class UserData
|
||||
{
|
||||
public:
|
||||
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(); }
|
||||
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; }
|
||||
void SetDescription( const char* description );
|
||||
@@ -55,6 +56,7 @@ private:
|
||||
|
||||
std::string m_program;
|
||||
uint64_t m_time;
|
||||
std::string m_filePath;
|
||||
|
||||
std::string m_description;
|
||||
ViewData m_viewData;
|
||||
|
||||
@@ -78,7 +78,7 @@ View::View( void(*cbMainThread)(const std::function<void()>&, bool), FileRead& f
|
||||
, m_stcb( stcb )
|
||||
, m_sscb( sscb )
|
||||
, 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_achievementsMgr( amgr )
|
||||
, m_achievements( s_config.achievements )
|
||||
@@ -738,7 +738,7 @@ bool View::DrawImpl()
|
||||
m_uarchSet = true;
|
||||
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 )
|
||||
{
|
||||
m_saveThread.join();
|
||||
@@ -1476,6 +1476,7 @@ bool View::Save( const char* fn, FileCompression comp, int zlevel, bool buildDic
|
||||
if( !f ) return false;
|
||||
|
||||
m_userData.StateShouldBePreserved();
|
||||
m_userData.SetFilePath( fn );
|
||||
m_saveThreadState.store( SaveThreadState::Saving, std::memory_order_relaxed );
|
||||
m_saveThread = std::thread( [this, f{std::move( f )}, buildDict] {
|
||||
Worker::MainThreadDataLockGuard lock = m_worker.ObtainLockForMainThread();
|
||||
|
||||
@@ -226,7 +226,7 @@ void View::DrawCompare()
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
catch( const tracy::UnsupportedVersion& e )
|
||||
|
||||
Reference in New Issue
Block a user