forked from qt-creator/qt-creator
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:
committed by
Orgad Shaneh
parent
1f0594050f
commit
96a9f1011f
@@ -189,13 +189,13 @@ QVariant CallModel::data(const QModelIndex &index, int role) const
|
|||||||
if (role == RelativeTotalCostRole) {
|
if (role == RelativeTotalCostRole) {
|
||||||
const quint64 totalCost = d->m_data->totalCost(d->m_event);
|
const quint64 totalCost = d->m_data->totalCost(d->m_event);
|
||||||
const quint64 callCost = call->cost(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) {
|
if (role == RelativeParentCostRole) {
|
||||||
const quint64 parentCost = d->m_function->inclusiveCost(d->m_event);
|
const quint64 parentCost = d->m_function->inclusiveCost(d->m_event);
|
||||||
const quint64 callCost = call->cost(d->m_event);
|
const quint64 callCost = call->cost(d->m_event);
|
||||||
return double(callCost) / parentCost;
|
return parentCost ? (double(callCost) / parentCost) : 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@@ -298,9 +298,9 @@ QVariant DataModel::data(const QModelIndex &index, int role) const
|
|||||||
if (role == RelativeParentCostRole || role == RelativeTotalCostRole) {
|
if (role == RelativeParentCostRole || role == RelativeTotalCostRole) {
|
||||||
const quint64 totalCost = d->m_data->totalCost(d->m_event);
|
const quint64 totalCost = d->m_data->totalCost(d->m_event);
|
||||||
if (index.column() == SelfCostColumn)
|
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)
|
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)
|
if (role == LineNumberRole)
|
||||||
|
Reference in New Issue
Block a user