From b55fa19f728454e081082bce408a61d4684b610f Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 1 Feb 2020 18:01:24 +0100 Subject: [PATCH] Fix division by zero. --- server/TracyView.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 29dd0546..eb701139 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -5873,8 +5873,11 @@ void View::DrawZoneInfoWindow() if( m_worker.AreSourceLocationZonesReady() ) { auto& zoneData = m_worker.GetZonesForSourceLocation( ev.SrcLoc() ); - ImGui::SameLine(); - ImGui::TextDisabled( "(%.2f%% of average time)", float( ztime ) / zoneData.total * zoneData.zones.size() * 100 ); + if( zoneData.total > 0 ) + { + ImGui::SameLine(); + ImGui::TextDisabled( "(%.2f%% of average time)", float( ztime ) / zoneData.total * zoneData.zones.size() * 100 ); + } } #endif TextFocused( "Self time:", TimeToString( selftime ) ); @@ -13955,8 +13958,11 @@ void View::ZoneTooltip( const ZoneEvent& ev ) if( m_worker.AreSourceLocationZonesReady() ) { auto& zoneData = m_worker.GetZonesForSourceLocation( ev.SrcLoc() ); - ImGui::SameLine(); - ImGui::TextDisabled( "(%.2f%% of average time)", float( ztime ) / zoneData.total * zoneData.zones.size() * 100 ); + if( zoneData.total > 0 ) + { + ImGui::SameLine(); + ImGui::TextDisabled( "(%.2f%% of average time)", float( ztime ) / zoneData.total * zoneData.zones.size() * 100 ); + } } #endif TextFocused( "Self time:", TimeToString( selftime ) );