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

@@ -1757,7 +1757,7 @@ bool GitClient::getCommitData(const QString &workingDirectory,
return false;
}
const int separatorPos = sp.stdOut.indexOf(QLatin1Char('@'));
QTC_ASSERT(separatorPos != -1, return false)
QTC_ASSERT(separatorPos != -1, return false);
commitData->amendSHA1= sp.stdOut.left(separatorPos);
*commitTemplate = sp.stdOut.mid(separatorPos + 1);
} else {

View File

@@ -116,7 +116,7 @@ QSharedPointer<VcsBase::AbstractCheckoutJob> GitoriousCloneWizard::createJob(con
QString *checkoutPath)
{
const Git::CloneWizardPage *cwp = qobject_cast<const Git::CloneWizardPage *>(parameterPages.back());
QTC_ASSERT(cwp, return QSharedPointer<VcsBase::AbstractCheckoutJob>())
QTC_ASSERT(cwp, return QSharedPointer<VcsBase::AbstractCheckoutJob>());
return cwp->createCheckoutJob(checkoutPath);
}

View File

@@ -582,35 +582,35 @@ void GitPlugin::submitEditorDiff(const QStringList &unstaged, const QStringList
void GitPlugin::diffCurrentFile()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return)
QTC_ASSERT(state.hasFile(), return);
m_gitClient->diff(state.currentFileTopLevel(), QStringList(), state.relativeCurrentFile());
}
void GitPlugin::diffCurrentProject()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return)
QTC_ASSERT(state.hasProject(), return);
m_gitClient->diff(state.currentProjectTopLevel(), QStringList(), state.relativeCurrentProject());
}
void GitPlugin::diffRepository()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return)
QTC_ASSERT(state.hasTopLevel(), return);
m_gitClient->diff(state.topLevel(), QStringList(), QStringList());
}
void GitPlugin::logFile()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return)
QTC_ASSERT(state.hasFile(), return);
m_gitClient->log(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()), true);
}
void GitPlugin::blameFile()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return)
QTC_ASSERT(state.hasFile(), return);
const int lineNumber = VcsBase::VcsBaseEditorWidget::lineNumberOfCurrentEditor(state.currentFile());
m_gitClient->blame(state.currentFileTopLevel(), QStringList(), state.relativeCurrentFile(), QString(), lineNumber);
}
@@ -618,14 +618,14 @@ void GitPlugin::blameFile()
void GitPlugin::logProject()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return)
QTC_ASSERT(state.hasProject(), return);
m_gitClient->log(state.currentProjectTopLevel(), state.relativeCurrentProject());
}
void GitPlugin::undoFileChanges(bool revertStaging)
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return)
QTC_ASSERT(state.hasFile(), return);
Core::FileChangeBlocker fcb(state.currentFile());
m_gitClient->revert(QStringList(state.currentFile()), revertStaging);
}
@@ -638,7 +638,7 @@ void GitPlugin::undoUnstagedFileChanges()
void GitPlugin::undoRepositoryChanges()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return)
QTC_ASSERT(state.hasTopLevel(), return);
const QString msg = tr("Undo all pending changes to the repository\n%1?").arg(QDir::toNativeSeparators(state.topLevel()));
const QMessageBox::StandardButton answer
= QMessageBox::question(Core::ICore::mainWindow(),
@@ -653,14 +653,14 @@ void GitPlugin::undoRepositoryChanges()
void GitPlugin::stageFile()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return)
QTC_ASSERT(state.hasFile(), return);
m_gitClient->addFile(state.currentFileTopLevel(), state.relativeCurrentFile());
}
void GitPlugin::unstageFile()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return)
QTC_ASSERT(state.hasFile(), return);
m_gitClient->synchronousReset(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
}
@@ -684,7 +684,7 @@ void GitPlugin::startCommit(bool amend)
}
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return)
QTC_ASSERT(state.hasTopLevel(), return);
QString errorMessage, commitTemplate;
CommitData data;
@@ -818,7 +818,7 @@ void GitPlugin::pull()
void GitPlugin::push()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return)
QTC_ASSERT(state.hasTopLevel(), return);
m_gitClient->synchronousPush(state.topLevel());
}
@@ -838,7 +838,7 @@ static inline GitClientMemberFunc memberFunctionFromAction(const QObject *o)
void GitPlugin::gitClientMemberFuncRepositoryAction()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return)
QTC_ASSERT(state.hasTopLevel(), return);
// Retrieve member function and invoke on repository
GitClientMemberFunc func = memberFunctionFromAction(sender());
QTC_ASSERT(func, return);
@@ -848,7 +848,7 @@ void GitPlugin::gitClientMemberFuncRepositoryAction()
void GitPlugin::cleanProject()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return)
QTC_ASSERT(state.hasProject(), return);
cleanRepository(state.currentProjectPath());
}
@@ -963,7 +963,7 @@ void GitPlugin::stash()
{
// Simple stash without prompt, reset repo.
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return)
QTC_ASSERT(state.hasTopLevel(), return);
const QString id = m_gitClient->synchronousStash(state.topLevel(), QString(), 0);
if (!id.isEmpty() && m_stashDialog)
m_stashDialog->refresh(state.topLevel(), true);
@@ -973,7 +973,7 @@ void GitPlugin::stashSnapshot()
{
// Prompt for description, restore immediately and keep on working.
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return)
QTC_ASSERT(state.hasTopLevel(), return);
const QString id = m_gitClient->synchronousStash(state.topLevel(), QString(), GitClient::StashImmediateRestore|GitClient::StashPromptDescription);
if (!id.isEmpty() && m_stashDialog)
m_stashDialog->refresh(state.topLevel(), true);

View File

@@ -211,7 +211,7 @@ void StashDialog::deleteAll()
void StashDialog::deleteSelection()
{
const QList<int> rows = selectedRows();
QTC_ASSERT(!rows.isEmpty(), return)
QTC_ASSERT(!rows.isEmpty(), return);
const QString title = tr("Delete Stashes");
if (!ask(title, tr("Do you want to delete %n stash(es)?", 0, rows.size())))
return;
@@ -229,7 +229,7 @@ void StashDialog::deleteSelection()
void StashDialog::showCurrent()
{
const int index = currentRow();
QTC_ASSERT(index >= 0, return)
QTC_ASSERT(index >= 0, return);
gitClient()->show(m_repository, m_model->at(index).name);
}
@@ -302,7 +302,7 @@ bool StashDialog::promptForRestore(QString *stash,
if (gitClient()->synchronousStash(m_repository, QString(), GitClient::StashPromptDescription).isEmpty())
return false;
*stash = nextStash(*stash); // Our stash id to be restored changed
QTC_ASSERT(!stash->isEmpty(), return false)
QTC_ASSERT(!stash->isEmpty(), return false);
break;
case ModifiedRepositoryDiscard:
if (!gitClient()->synchronousReset(m_repository))
@@ -336,7 +336,7 @@ static inline QString msgRestoreFailedTitle(const QString &stash)
void StashDialog::restoreCurrent()
{
const int index = currentRow();
QTC_ASSERT(index >= 0, return)
QTC_ASSERT(index >= 0, return);
QString errorMessage;
QString name = m_model->at(index).name;
// Make sure repository is not modified, restore. The command will
@@ -354,8 +354,8 @@ void StashDialog::restoreCurrent()
void StashDialog::restoreCurrentInBranch()
{
const int index = currentRow();
QTC_ASSERT(index >= 0, return)
QString errorMessage;
QTC_ASSERT(index >= 0, return);
QString errorMessage;
QString branch;
QString name = m_model->at(index).name;
const bool success = promptForRestore(&name, &branch, &errorMessage)