1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Fix processing FrameData with no frames

This commit is contained in:
Valerii Fediunin 2024-05-23 11:17:28 +02:00
parent 8983e14e18
commit bb7246b7a3
6 changed files with 11 additions and 5 deletions

View File

@ -95,7 +95,7 @@ void View::DrawTimelineFrames( const FrameData& frames )
{
const std::pair <int, int> zrange = m_worker.GetFrameRange( frames, m_vd.zvStart, m_vd.zvEnd );
if( zrange.first < 0 ) return;
if( m_worker.GetFrameBegin( frames, zrange.first ) > m_vd.zvEnd || m_worker.GetFrameEnd( frames, zrange.second ) < m_vd.zvStart ) return;
if( m_worker.GetFrameBegin( frames, zrange.first ) > m_vd.zvEnd || m_worker.GetFrameEnd( frames, zrange.second - 1 ) < m_vd.zvStart ) return;
const auto wpos = ImGui::GetCursorScreenPos();
const auto dpos = wpos + ImVec2( 0.5f, 0.5f );

View File

@ -243,7 +243,7 @@ void View::DrawMessageLine( const MessageData& msg, bool hasCallstack, int& idx
{
m_msgHighlight = &msg;
if( m_showMessageImages )
if( m_showMessageImages && m_worker.GetFrameCount( *m_frames ) > 0 )
{
const auto frameIdx = m_worker.GetFrameRange( *m_frames, msg.time, msg.time ).first;
auto fi = m_worker.GetFrameImage( *m_frames, frameIdx );

View File

@ -74,7 +74,7 @@ void View::ZoomToRange( int64_t start, int64_t end, bool pause )
void View::ZoomToPrevFrame()
{
if( m_vd.zvStart >= m_worker.GetFrameBegin( *m_frames, 0 ) )
if( m_worker.GetFrameCount( *m_frames ) > 0 && m_vd.zvStart >= m_worker.GetFrameBegin( *m_frames, 0 ) )
{
size_t frame;
if( m_frames->continuous )
@ -98,6 +98,8 @@ void View::ZoomToPrevFrame()
void View::ZoomToNextFrame()
{
if( m_worker.GetFrameCount( *m_frames ) == 0 ) return;
int64_t start;
if( m_zoomAnim.active )
{
@ -133,6 +135,7 @@ void View::CenterAtTime( int64_t t )
void View::SetViewToLastFrames()
{
const int total = m_worker.GetFrameCount( *m_frames );
if( total == 0 ) return;
m_vd.zvStart = m_worker.GetFrameBegin( *m_frames, std::max( 0, total - 4 ) );
if( total == 1 )

View File

@ -310,7 +310,7 @@ void View::DrawTimeline()
auto& frames = m_worker.GetFrames();
for( auto fd : frames )
{
if( Vis( fd ) )
if( Vis( fd ) && m_worker.GetFrameCount( *fd ) > 0 )
{
DrawTimelineFrames( *fd );
}

View File

@ -183,7 +183,7 @@ void View::DrawInfo()
ImGui::TreePop();
}
if( m_worker.AreFramesUsed() && ImGui::TreeNode( "Frame statistics" ) )
if( m_worker.AreFramesUsed() && ImGui::TreeNode( "Frame statistics" ) && m_worker.GetFrameCount( *m_frames ) > 0 )
{
auto fsz = m_worker.GetFullFrameCount( *m_frames );
if( fsz != 0 )

View File

@ -2074,6 +2074,7 @@ int64_t Worker::GetFirstTime() const
int64_t Worker::GetFrameTime( const FrameData& fd, size_t idx ) const
{
assert( idx < fd.frames.size() );
if( fd.continuous )
{
if( idx < fd.frames.size() - 1 )
@ -2108,6 +2109,7 @@ int64_t Worker::GetFrameBegin( const FrameData& fd, size_t idx ) const
int64_t Worker::GetFrameEnd( const FrameData& fd, size_t idx ) const
{
assert( idx < fd.frames.size() );
if( fd.continuous )
{
if( idx < fd.frames.size() - 1 )
@ -2142,6 +2144,7 @@ const FrameImage* Worker::GetFrameImage( const FrameData& fd, size_t idx ) const
std::pair<int, int> Worker::GetFrameRange( const FrameData& fd, int64_t from, int64_t to )
{
assert( !fd.frames.empty() );
auto zitbegin = std::lower_bound( fd.frames.begin(), fd.frames.end(), from, [] ( const auto& lhs, const auto& rhs ) { return lhs.start < rhs; } );
if( zitbegin == fd.frames.end() ) zitbegin--;