From 399d94528fce7eab096ed8d9b6f06299e2ee103d Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Thu, 24 Mar 2016 20:33:10 +0100 Subject: [PATCH] Never divide by zero. --- gui/callercalleemodel.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gui/callercalleemodel.cpp b/gui/callercalleemodel.cpp index 3dc8f60..c909620 100644 --- a/gui/callercalleemodel.cpp +++ b/gui/callercalleemodel.cpp @@ -23,6 +23,8 @@ #include +#include + namespace{ /// TODO: share code QString basename(const QString& path) @@ -227,12 +229,12 @@ QVariant CallerCalleeModel::data(const QModelIndex& index, int role) const stream << '\n'; stream << i18n("inclusive: allocated %1 over %2 calls (%3 temporary, i.e. %4%), peak at %5, leaked %6", m_format.formatByteSize(row.inclusiveCost.allocated), row.inclusiveCost.allocations, row.inclusiveCost.temporary, - round(float(row.inclusiveCost.temporary) * 100.f * 100.f / row.inclusiveCost.allocations) / 100.f, + round(float(row.inclusiveCost.temporary) * 100.f * 100.f / std::max(uint64_t(1), row.inclusiveCost.allocations)) / 100.f, m_format.formatByteSize(row.inclusiveCost.peak), m_format.formatByteSize(row.inclusiveCost.leaked)); stream << '\n'; stream << i18n("self: allocated %1 over %2 calls (%3 temporary, i.e. %4%), peak at %5, leaked %6", m_format.formatByteSize(row.selfCost.allocated), row.selfCost.allocations, row.selfCost.temporary, - round(float(row.selfCost.temporary) * 100.f * 100.f / row.selfCost.allocations) / 100.f, + round(float(row.selfCost.temporary) * 100.f * 100.f / std::max(uint64_t(1), row.selfCost.allocations)) / 100.f, m_format.formatByteSize(row.selfCost.peak), m_format.formatByteSize(row.selfCost.leaked)); stream << '\n'; stream << ""; -- 2.7.4