Replace Q_ASSERTs with QTC_ASSERTs

or even with QTC_CHECKs.

Change-Id: I6df67f088bb2f944f0a1abd751fdb192db2be298
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Tobias Hunger
2012-01-12 11:32:45 +01:00
committed by hjk
parent e4a0bdd8e2
commit fab53ac364
15 changed files with 38 additions and 27 deletions

View File

@@ -36,6 +36,7 @@
#include <texteditor/texteditorsettings.h> #include <texteditor/texteditorsettings.h>
#include <texteditor/fontsettings.h> #include <texteditor/fontsettings.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
#include <utils/qtcassert.h>
#include <QtGui/QSyntaxHighlighter> #include <QtGui/QSyntaxHighlighter>
#include <QtGui/QTextEdit> #include <QtGui/QTextEdit>
@@ -79,7 +80,7 @@ BazaarSubmitHighlighter::BazaarSubmitHighlighter(QTextEdit * parent) :
m_keywordPattern(QLatin1String("^\\w+:")), m_keywordPattern(QLatin1String("^\\w+:")),
m_hashChar(QLatin1Char('#')) m_hashChar(QLatin1Char('#'))
{ {
Q_ASSERT(m_keywordPattern.isValid()); QTC_CHECK(m_keywordPattern.isValid());
} }
void BazaarSubmitHighlighter::highlightBlock(const QString &text) void BazaarSubmitHighlighter::highlightBlock(const QString &text)

View File

@@ -33,6 +33,7 @@
#include "pullorpushdialog.h" #include "pullorpushdialog.h"
#include "ui_pullorpushdialog.h" #include "ui_pullorpushdialog.h"
#include <utils/qtcassert.h>
using namespace Bazaar::Internal; using namespace Bazaar::Internal;
@@ -87,19 +88,19 @@ QString PullOrPushDialog::revision() const
bool PullOrPushDialog::isLocalOptionEnabled() const bool PullOrPushDialog::isLocalOptionEnabled() const
{ {
Q_ASSERT(m_mode == PullMode); QTC_ASSERT(m_mode == PullMode, return false);
return m_ui->localCheckBox->isChecked(); return m_ui->localCheckBox->isChecked();
} }
bool PullOrPushDialog::isUseExistingDirectoryOptionEnabled() const bool PullOrPushDialog::isUseExistingDirectoryOptionEnabled() const
{ {
Q_ASSERT(m_mode == PushMode); QTC_ASSERT(m_mode == PushMode, return false);
return m_ui->useExistingDirCheckBox->isChecked(); return m_ui->useExistingDirCheckBox->isChecked();
} }
bool PullOrPushDialog::isCreatePrefixOptionEnabled() const bool PullOrPushDialog::isCreatePrefixOptionEnabled() const
{ {
Q_ASSERT(m_mode == PushMode); QTC_ASSERT(m_mode == PushMode, return false);
return m_ui->createPrefixCheckBox->isChecked(); return m_ui->createPrefixCheckBox->isChecked();
} }

View File

@@ -85,9 +85,9 @@ public:
VcsInfo *findInCache(const QString &dir) VcsInfo *findInCache(const QString &dir)
{ {
Q_ASSERT(QDir(dir).isAbsolute()); QTC_ASSERT(QDir(dir).isAbsolute(), return 0);
Q_ASSERT(!dir.endsWith(QLatin1Char('/'))); QTC_ASSERT(!dir.endsWith(QLatin1Char('/')), return 0);
Q_ASSERT(QDir::fromNativeSeparators(dir) == dir); QTC_ASSERT(QDir::fromNativeSeparators(dir) == dir, return 0);
const QMap<QString, VcsInfo *>::const_iterator it = m_cachedMatches.constFind(dir); const QMap<QString, VcsInfo *>::const_iterator it = m_cachedMatches.constFind(dir);
if (it != m_cachedMatches.constEnd()) if (it != m_cachedMatches.constEnd())

View File

@@ -39,6 +39,7 @@
#include "stashdialog.h" // Label helpers #include "stashdialog.h" // Label helpers
#include <utils/checkablemessagebox.h> #include <utils/checkablemessagebox.h>
#include <utils/qtcassert.h>
#include <vcsbase/vcsbaseoutputwindow.h> #include <vcsbase/vcsbaseoutputwindow.h>
#include <QtGui/QItemSelectionModel> #include <QtGui/QItemSelectionModel>
@@ -151,7 +152,7 @@ void BranchDialog::add()
void BranchDialog::checkout() void BranchDialog::checkout()
{ {
QModelIndex idx = selectedIndex(); QModelIndex idx = selectedIndex();
Q_ASSERT(m_model->isLocal(idx)); QTC_CHECK(m_model->isLocal(idx));
m_model->checkoutBranch(idx); m_model->checkoutBranch(idx);
enableButtons(); enableButtons();
@@ -161,7 +162,7 @@ void BranchDialog::checkout()
void BranchDialog::remove() void BranchDialog::remove()
{ {
QModelIndex selected = selectedIndex(); QModelIndex selected = selectedIndex();
Q_ASSERT(selected != m_model->currentBranch()); // otherwise the button would not be enabled! QTC_CHECK(selected != m_model->currentBranch()); // otherwise the button would not be enabled!
QString branchName = m_model->branchName(selected); QString branchName = m_model->branchName(selected);
if (branchName.isEmpty()) if (branchName.isEmpty())

View File

@@ -33,6 +33,7 @@
#include "branchmodel.h" #include "branchmodel.h"
#include "gitclient.h" #include "gitclient.h"
#include <utils/qtcassert.h>
#include <vcsbase/vcsbaseoutputwindow.h> #include <vcsbase/vcsbaseoutputwindow.h>
#include <QtGui/QFont> #include <QtGui/QFont>
@@ -103,7 +104,7 @@ public:
QStringList fullName() const QStringList fullName() const
{ {
Q_ASSERT(isLeaf()); QTC_ASSERT(isLeaf(), return QStringList());
QStringList fn; QStringList fn;
QList<const BranchNode *> nodes; QList<const BranchNode *> nodes;
@@ -172,7 +173,7 @@ BranchModel::BranchModel(GitClient *client, QObject *parent) :
m_client(client), m_client(client),
m_rootNode(new BranchNode) m_rootNode(new BranchNode)
{ {
Q_ASSERT(m_client); QTC_CHECK(m_client);
m_rootNode->append(new BranchNode(tr("Local Branches"))); m_rootNode->append(new BranchNode(tr("Local Branches")));
} }

View File

@@ -113,8 +113,8 @@ static CommitData::FileState stateFor(const QChar &c)
static bool checkLine(const QString &stateInfo, const QString &file, QList<CommitData::StateFilePair> *files) static bool checkLine(const QString &stateInfo, const QString &file, QList<CommitData::StateFilePair> *files)
{ {
Q_ASSERT(stateInfo.count() == 2); QTC_ASSERT(stateInfo.count() == 2, return false);
Q_ASSERT(files); QTC_ASSERT(files, return false);
if (stateInfo == "??") { if (stateInfo == "??") {
files->append(qMakePair(CommitData::UntrackedFile, file)); files->append(qMakePair(CommitData::UntrackedFile, file));

View File

@@ -238,7 +238,7 @@ public:
void setEditor(VcsBase::VcsBaseEditorWidget *editor) void setEditor(VcsBase::VcsBaseEditorWidget *editor)
{ {
Q_ASSERT(editor); QTC_ASSERT(editor, return);
m_editor = editor; m_editor = editor;
} }
@@ -354,7 +354,7 @@ GitClient::GitClient(GitSettings *settings) :
m_repositoryChangedSignalMapper(0), m_repositoryChangedSignalMapper(0),
m_settings(settings) m_settings(settings)
{ {
Q_ASSERT(settings); QTC_CHECK(settings);
connect(m_core, SIGNAL(saveSettingsRequested()), this, SLOT(saveSettings())); connect(m_core, SIGNAL(saveSettingsRequested()), this, SLOT(saveSettings()));
} }
@@ -411,7 +411,7 @@ VcsBase::VcsBaseEditorWidget *GitClient::createVcsEditor(const Core::Id &id,
QWidget *configWidget) const QWidget *configWidget) const
{ {
VcsBase::VcsBaseEditorWidget *rc = 0; VcsBase::VcsBaseEditorWidget *rc = 0;
Q_ASSERT(!findExistingVCSEditor(registerDynamicProperty, dynamicPropertyValue)); QTC_CHECK(!findExistingVCSEditor(registerDynamicProperty, dynamicPropertyValue));
// Create new, set wait message, set up with source and codec // Create new, set wait message, set up with source and codec
Core::IEditor *outputEditor = m_core->editorManager()->openEditorWithContents(id, &title, m_msgWait); Core::IEditor *outputEditor = m_core->editorManager()->openEditorWithContents(id, &title, m_msgWait);
@@ -1553,7 +1553,7 @@ QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryUR
// split "82bfad2f51d34e98b18982211c82220b8db049b<tab>refs/heads/master" // split "82bfad2f51d34e98b18982211c82220b8db049b<tab>refs/heads/master"
foreach(const QString &line, resp.stdOut.split(QLatin1Char('\n'))) { foreach(const QString &line, resp.stdOut.split(QLatin1Char('\n'))) {
if (line.endsWith("\tHEAD")) { if (line.endsWith("\tHEAD")) {
Q_ASSERT(headSha.isNull()); QTC_CHECK(headSha.isNull());
headSha = line.left(line.indexOf(QChar('\t'))); headSha = line.left(line.indexOf(QChar('\t')));
continue; continue;
} }

View File

@@ -171,17 +171,17 @@ static QByteArray removeAnnotationDate(const QByteArray &b)
return QByteArray(b); return QByteArray(b);
// Copy over the parts that have not changed into a new byte array // Copy over the parts that have not changed into a new byte array
Q_ASSERT(b.size() >= parenPos);
QByteArray result; QByteArray result;
QTC_ASSERT(b.size() >= parenPos, return result);
int prevPos = 0; int prevPos = 0;
int pos = b.indexOf('\n', 0) + 1; int pos = b.indexOf('\n', 0) + 1;
forever { forever {
Q_ASSERT(prevPos < pos); QTC_CHECK(prevPos < pos);
int afterParen = prevPos + parenPos; int afterParen = prevPos + parenPos;
result.append(b.constData() + prevPos, datePos); result.append(b.constData() + prevPos, datePos);
result.append(b.constData() + afterParen, pos - afterParen); result.append(b.constData() + afterParen, pos - afterParen);
prevPos = pos; prevPos = pos;
Q_ASSERT(prevPos != 0); QTC_CHECK(prevPos != 0);
if (pos == b.size()) if (pos == b.size())
break; break;

View File

@@ -39,6 +39,7 @@
#include <QtNetwork/QNetworkReply> #include <QtNetwork/QNetworkReply>
#include <utils/qtcassert.h>
#include <utils/networkaccessmanager.h> #include <utils/networkaccessmanager.h>
enum { debug = 0 }; enum { debug = 0 };
@@ -347,7 +348,7 @@ GitoriousRepository GitoriousProjectReader::readRepository(QXmlStreamReader &rea
void GitoriousProjectReader::readUnknownElement(QXmlStreamReader &reader) void GitoriousProjectReader::readUnknownElement(QXmlStreamReader &reader)
{ {
Q_ASSERT(reader.isStartElement()); QTC_ASSERT(reader.isStartElement(), return);
while (!reader.atEnd()) { while (!reader.atEnd()) {
reader.readNext(); reader.readNext();
@@ -446,7 +447,7 @@ void Gitorious::listCategoriesReply(int index, QByteArray dataB)
const QString data = QString::fromUtf8(dataB); const QString data = QString::fromUtf8(dataB);
// Cut out the contents of the anchors // Cut out the contents of the anchors
QRegExp pattern = QRegExp(QLatin1String("<a href=[^>]+>([^<]+)</a>")); QRegExp pattern = QRegExp(QLatin1String("<a href=[^>]+>([^<]+)</a>"));
Q_ASSERT(pattern.isValid()); QTC_CHECK(pattern.isValid());
GitoriousHost::CategoryList &categories = m_hosts[index].categories; GitoriousHost::CategoryList &categories = m_hosts[index].categories;
for (int pos = pattern.indexIn(data) ; pos != -1; ) { for (int pos = pattern.indexIn(data) ; pos != -1; ) {
const QString cat = pattern.cap(1); const QString cat = pattern.cap(1);

View File

@@ -232,7 +232,7 @@ void GitoriousProjectWidget::setDescription(const QString &description,
// Should the text contain an URL, extract // Should the text contain an URL, extract
// Do not fall for "(http://XX)", strip special characters // Do not fall for "(http://XX)", strip special characters
static const QRegExp urlRegExp(QLatin1String("(http://[\\w\\.-]+/[a-zA-Z0-9/\\-&]*)")); static const QRegExp urlRegExp(QLatin1String("(http://[\\w\\.-]+/[a-zA-Z0-9/\\-&]*)"));
Q_ASSERT(urlRegExp.isValid()); QTC_CHECK(urlRegExp.isValid());
if (urlRegExp.indexIn(description) != -1) { if (urlRegExp.indexIn(description) != -1) {
*url= urlRegExp.cap(1); *url= urlRegExp.cap(1);
} else { } else {

View File

@@ -35,6 +35,7 @@
#include "gitconstants.h" #include "gitconstants.h"
#include "commitdata.h" #include "commitdata.h"
#include <utils/qtcassert.h>
#include <vcsbase/submitfilemodel.h> #include <vcsbase/submitfilemodel.h>
#include <QtCore/QDebug> #include <QtCore/QDebug>

View File

@@ -36,6 +36,7 @@
#include <texteditor/texteditorsettings.h> #include <texteditor/texteditorsettings.h>
#include <texteditor/fontsettings.h> #include <texteditor/fontsettings.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
#include <utils/qtcassert.h>
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
#include <QtGui/QRegExpValidator> #include <QtGui/QRegExpValidator>
@@ -78,7 +79,7 @@ GitSubmitHighlighter::GitSubmitHighlighter(QTextEdit * parent) :
m_keywordPattern(QLatin1String("^\\w+:")), m_keywordPattern(QLatin1String("^\\w+:")),
m_hashChar(QLatin1Char('#')) m_hashChar(QLatin1Char('#'))
{ {
Q_ASSERT(m_keywordPattern.isValid()); QTC_CHECK(m_keywordPattern.isValid());
} }
void GitSubmitHighlighter::highlightBlock(const QString &text) void GitSubmitHighlighter::highlightBlock(const QString &text)

View File

@@ -35,6 +35,7 @@
#include <texteditor/texteditorsettings.h> #include <texteditor/texteditorsettings.h>
#include <texteditor/fontsettings.h> #include <texteditor/fontsettings.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
#include <utils/qtcassert.h>
#include <QtGui/QSyntaxHighlighter> #include <QtGui/QSyntaxHighlighter>
#include <QtGui/QTextEdit> #include <QtGui/QTextEdit>
@@ -78,7 +79,7 @@ MercurialSubmitHighlighter::MercurialSubmitHighlighter(QTextEdit *parent) :
m_keywordPattern(QLatin1String("^\\w+:")), m_keywordPattern(QLatin1String("^\\w+:")),
m_hashChar(QLatin1Char('#')) m_hashChar(QLatin1Char('#'))
{ {
Q_ASSERT(m_keywordPattern.isValid()); QTC_CHECK(m_keywordPattern.isValid());
} }
void MercurialSubmitHighlighter::highlightBlock(const QString &text) void MercurialSubmitHighlighter::highlightBlock(const QString &text)

View File

@@ -36,6 +36,7 @@
#include "tasklistplugin.h" #include "tasklistplugin.h"
#include <projectexplorer/task.h> #include <projectexplorer/task.h>
#include <utils/qtcassert.h>
#include <QtGui/QAction> #include <QtGui/QAction>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
@@ -61,7 +62,7 @@ bool StopMonitoringHandler::canHandle(const ProjectExplorer::Task &task)
void StopMonitoringHandler::handle(const ProjectExplorer::Task &task) void StopMonitoringHandler::handle(const ProjectExplorer::Task &task)
{ {
Q_ASSERT(canHandle(task)); QTC_ASSERT(canHandle(task), return);
Q_UNUSED(task); Q_UNUSED(task);
TaskList::TaskListPlugin::instance()->stopMonitoring(); TaskList::TaskListPlugin::instance()->stopMonitoring();
} }

View File

@@ -40,6 +40,8 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/iversioncontrol.h> #include <coreplugin/iversioncontrol.h>
#include <utils/qtcassert.h>
namespace VcsBase { namespace VcsBase {
namespace Internal { namespace Internal {
@@ -65,7 +67,7 @@ VcsConfigurationPage::VcsConfigurationPage(const Core::IVersionControl *vc, QWid
QWizardPage(parent), QWizardPage(parent),
d(new Internal::VcsConfigurationPagePrivate) d(new Internal::VcsConfigurationPagePrivate)
{ {
Q_ASSERT(vc); QTC_CHECK(vc);
setTitle(tr("Configuration")); setTitle(tr("Configuration"));
setSubTitle(tr("Please configure <b>%1</b> now.").arg(vc->displayName())); setSubTitle(tr("Please configure <b>%1</b> now.").arg(vc->displayName()));