qtcassert: move actual printing to separate function and enforce style

This also allows simple setting of breakpoints on failed asserts.

Change-Id: I6dd84cbfaf659d57e39f3447386cebc0221b2b84
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
hjk
2012-04-17 08:01:25 +02:00
committed by hjk
parent 37e3853090
commit 5b0bf61640
95 changed files with 347 additions and 297 deletions

View File

@@ -94,14 +94,13 @@ QString toOptionString(CallgrindController::Option option)
}
}
void CallgrindController::run(Option option)
{
if (m_process) {
emit statusMessage(tr("Previous command has not yet finished."));
return;
}
QTC_ASSERT(m_valgrindProc, return)
QTC_ASSERT(m_valgrindProc, return);
if (RemoteValgrindProcess *remote = qobject_cast<RemoteValgrindProcess *>(m_valgrindProc))
m_process = new RemoteValgrindProcess(remote->connection(), this);
@@ -150,7 +149,7 @@ void CallgrindController::run(Option option)
void CallgrindController::processError(QProcess::ProcessError)
{
QTC_ASSERT(m_process, return)
QTC_ASSERT(m_process, return);
const QString error = m_process->errorString();
emit statusMessage(QString("An error occurred while trying to run %1: %2").arg(CALLGRIND_CONTROL_BINARY).arg(error));

View File

@@ -146,7 +146,7 @@ void DataModel::setCostEvent(int event)
if (!d->m_data)
return;
QTC_ASSERT(event >= 0 && d->m_data->events().size() > event, return)
QTC_ASSERT(event >= 0 && d->m_data->events().size() > event, return);
beginResetModel();
d->m_event = event;
d->updateFunctions();

View File

@@ -177,7 +177,7 @@ QString ParseData::prettyStringForEvent(const QString &event)
Indirect branches executed (Bi) and indirect branches mispredicted (Bim)
*/
QTC_ASSERT(event.size() >= 2, return event) // should not happen
QTC_ASSERT(event.size() >= 2, return event); // should not happen
const bool isMiss = event.contains(QLatin1Char('m')); // else hit
const bool isRead = event.contains(QLatin1Char('r')); // else write

View File

@@ -268,7 +268,7 @@ void Parser::Private::parse(QIODevice *device)
}
}
#endif
QTC_ASSERT(calledFunction, continue)
QTC_ASSERT(calledFunction, continue);
callData.call->setCallee(calledFunction);
calledFunction->addIncomingCall(callData.call);

View File

@@ -151,9 +151,9 @@ bool DataProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_
// check minimum inclusive costs
DataModel *model = dataModel();
QTC_ASSERT(model, return false) // as always: this should never happen
QTC_ASSERT(model, return false); // as always: this should never happen
const ParseData *data = model->parseData();
QTC_ASSERT(data, return false)
QTC_ASSERT(data, return false);
if (m_minimumInclusiveCostRatio != 0.0) {
const quint64 totalCost = data->totalCost(0);
const quint64 inclusiveCost = func->inclusiveCost(0);

View File

@@ -59,8 +59,8 @@ void CallgrindTextMark::paint(QPainter *painter, const QRect &paintRect) const
bool ok;
qreal costs = m_modelIndex.data(RelativeTotalCostRole).toReal(&ok);
QTC_ASSERT(ok, return)
QTC_ASSERT(costs >= 0.0 && costs <= 100.0, return)
QTC_ASSERT(ok, return);
QTC_ASSERT(costs >= 0.0 && costs <= 100.0, return);
painter->save();

View File

@@ -399,7 +399,7 @@ void CallgrindToolPrivate::updateCostFormat()
void CallgrindToolPrivate::handleFilterProjectCosts()
{
ProjectExplorer::Project *pro = ProjectExplorer::ProjectExplorerPlugin::currentProject();
QTC_ASSERT(pro, return)
QTC_ASSERT(pro, return);
if (m_filterProjectCosts->isChecked()) {
const QString projectDir = pro->projectDirectory();
@@ -472,7 +472,7 @@ void CallgrindToolPrivate::setParseData(ParseData *data)
void CallgrindToolPrivate::updateEventCombo()
{
QTC_ASSERT(m_eventCombo, return)
QTC_ASSERT(m_eventCombo, return);
m_eventCombo->clear();
@@ -920,10 +920,10 @@ void CallgrindToolPrivate::requestContextMenu(TextEditor::ITextEditor *editor, i
void CallgrindToolPrivate::handleShowCostsAction()
{
const QAction *action = qobject_cast<QAction *>(sender());
QTC_ASSERT(action, return)
QTC_ASSERT(action, return);
const Function *func = action->data().value<const Function *>();
QTC_ASSERT(func, return)
QTC_ASSERT(func, return);
selectFunction(func);
}
@@ -972,7 +972,7 @@ void CallgrindToolPrivate::takeParserData(CallgrindEngine *engine)
void CallgrindToolPrivate::createTextMarks()
{
DataModel *model = m_dataModel;
QTC_ASSERT(model, return)
QTC_ASSERT(model, return);
QList<QString> locations;
for (int row = 0; row < model->rowCount(); ++row) {

View File

@@ -72,7 +72,7 @@ static QString suppressionText(const Error &error)
// workaround: https://bugs.kde.org/show_bug.cgi?id=255822
if (sup.frames().size() >= 24)
sup.setFrames(sup.frames().mid(0, 23));
QTC_ASSERT(sup.frames().size() < 24, /**/)
QTC_ASSERT(sup.frames().size() < 24, /**/);
// try to set some useful name automatically, instead of "insert_name_here"
// we take the last stack frame and append the suppression kind, e.g.: