Valgrind: Prevent division by zero

Change-Id: Idf695a99c2f8cf53b0d0e0268a848c58a85af3cb
Reviewed-by: hjk <hjk@theqtcompany.com>
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2016-01-26 16:11:09 +02:00
committed by Orgad Shaneh
parent 1f0594050f
commit 96a9f1011f
2 changed files with 4 additions and 4 deletions

View File

@@ -189,13 +189,13 @@ QVariant CallModel::data(const QModelIndex &index, int role) const
if (role == RelativeTotalCostRole) {
const quint64 totalCost = d->m_data->totalCost(d->m_event);
const quint64 callCost = call->cost(d->m_event);
return double(callCost) / totalCost;
return totalCost ? (double(callCost) / totalCost) : 0.0;
}
if (role == RelativeParentCostRole) {
const quint64 parentCost = d->m_function->inclusiveCost(d->m_event);
const quint64 callCost = call->cost(d->m_event);
return double(callCost) / parentCost;
return parentCost ? (double(callCost) / parentCost) : 0.0;
}
return QVariant();

View File

@@ -298,9 +298,9 @@ QVariant DataModel::data(const QModelIndex &index, int role) const
if (role == RelativeParentCostRole || role == RelativeTotalCostRole) {
const quint64 totalCost = d->m_data->totalCost(d->m_event);
if (index.column() == SelfCostColumn)
return double(func->selfCost(d->m_event)) / totalCost;
return totalCost ? (double(func->selfCost(d->m_event)) / totalCost) : 0.0;
if (index.column() == InclusiveCostColumn)
return double(func->inclusiveCost(d->m_event)) / totalCost;
return totalCost ? (double(func->inclusiveCost(d->m_event)) / totalCost) : 0.0;
}
if (role == LineNumberRole)