Commit 4a552ead authored by hjk's avatar hjk

use QTC_ASSERT instead of Q_ASSERT

parent e99d8ce3
......@@ -239,7 +239,7 @@ static void appendFileData(QIODevice *out, const QString &fileName)
static void appendFileData(QIODevice *out, QIODevice *in)
{
Q_ASSERT(!in->isSequential());
QTC_ASSERT(!in->isSequential(), return);
qint64 size = in->size();
QByteArray &b = theBuffer(size);
rawRead(in, b.data(), size);
......
......@@ -30,19 +30,22 @@
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
#include "formresizer.h"
#include "sizehandlerect.h"
#include "widgethostconstants.h"
#include <utils/qtcassert.h>
#include <QtDesigner/QDesignerFormWindowInterface>
#include <QtGui/QResizeEvent>
#include <QtGui/QPalette>
#include <QtGui/QLayout>
#include <QtGui/QFrame>
#include <QtGui/QResizeEvent>
#include <QtCore/QDebug>
enum { debugFormResizer=0 };
enum { debugFormResizer = 0 };
using namespace SharedTools::Internal;
......@@ -140,7 +143,7 @@ void FormResizer::setFormWindow(QDesignerFormWindowInterface *fw)
if (debugFormResizer)
qDebug() << "FormResizer::setFormWindow " << fw;
QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(m_frame->layout());
Q_ASSERT(layout);
QTC_ASSERT(layout, return);
if (layout->count())
delete layout->takeAt(0);
m_formWindow = fw;
......
......@@ -33,6 +33,8 @@
#include "indenter.h"
#include <utils/qtcassert.h>
using namespace SharedTools::IndenterInternal;
// --- Constants
......@@ -55,12 +57,12 @@ Constants::Constants() :
"|(?:public|protected|private|signals|Q_SIGNALS|default)(?:\\s+slots|\\s+Q_SLOTS)?\\s*"
")?:.*"))
{
m_literal.setMinimal( true );
m_inlineCComment.setMinimal( true );
Q_ASSERT(m_literal.isValid());
Q_ASSERT(m_label.isValid());
Q_ASSERT(m_inlineCComment.isValid());
Q_ASSERT(m_braceX.isValid());
Q_ASSERT(m_iflikeKeyword.isValid());
Q_ASSERT(m_caseLabel.isValid());
m_literal.setMinimal(true);
m_inlineCComment.setMinimal(true);
QTC_ASSERT(m_literal.isValid(), return);
QTC_ASSERT(m_label.isValid(), return);
QTC_ASSERT(m_inlineCComment.isValid(), return);
QTC_ASSERT(m_braceX.isValid(), return);
QTC_ASSERT(m_iflikeKeyword.isValid(), return);
QTC_ASSERT(m_caseLabel.isValid(), return);
}
......@@ -33,6 +33,8 @@
#include "procommandmanager.h"
#include <utils/qtcassert.h>
using namespace Qt4ProjectManager::Internal;
ProCommandGroup::ProCommandGroup(const QString &name)
......@@ -76,7 +78,7 @@ ProCommandManager::~ProCommandManager()
void ProCommandManager::beginGroup(const QString &name)
{
Q_ASSERT(!m_group);
QTC_ASSERT(!m_group, return);
if (m_pos != m_groups.count()) {
int removecount = m_groups.count() - m_pos;
......@@ -95,7 +97,7 @@ bool ProCommandManager::hasGroup() const
void ProCommandManager::endGroup()
{
Q_ASSERT(m_group);
QTC_ASSERT(m_group, return);
m_groups.append(m_group);
m_pos = m_groups.count();
......@@ -106,7 +108,7 @@ void ProCommandManager::endGroup()
bool ProCommandManager::command(ProCommand *cmd)
{
Q_ASSERT(m_group);
QTC_ASSERT(m_group, return false);
if (cmd->redo()) {
m_group->appendCommand(cmd);
......
......@@ -35,6 +35,8 @@
#include "proparserutils.h"
#include "proitems.h"
#include <utils/qtcassert.h>
#include <QtCore/QByteArray>
#include <QtCore/QDebug>
#include <QtCore/QDir>
......@@ -683,7 +685,7 @@ bool ProFileEvaluator::Private::visitProFunction(ProFunction *func)
QString text = func->text();
int lparen = text.indexOf(QLatin1Char('('));
int rparen = text.lastIndexOf(QLatin1Char(')'));
Q_ASSERT(lparen < rparen);
QTC_ASSERT(lparen < rparen, return false);
QString arguments = text.mid(lparen + 1, rparen - lparen - 1);
QString funcName = text.left(lparen);
......
This diff is collapsed.
......@@ -36,10 +36,12 @@
#include "namespace_global.h"
#include <utils/qtcassert.h>
#include <QtCore/QAbstractItemModel>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QMap>
#include <QtCore/QAbstractItemModel>
#include "shared_global_p.h"
......@@ -66,11 +68,11 @@ class Node
protected:
Node(File *file, Prefix *prefix) : m_file(file), m_prefix(prefix)
{
Q_ASSERT(m_prefix != NULL);
QTC_ASSERT(m_prefix, return);
}
public:
File * file() { return m_file; }
Prefix * prefix() { Q_ASSERT(m_prefix != NULL); return m_prefix; }
File *file() { return m_file; }
Prefix *prefix() { return m_prefix; }
private:
File *m_file;
Prefix *m_prefix;
......
......@@ -32,16 +32,20 @@
***************************************************************************/
#include "resourceview.h"
#include "undocommands_p.h"
#include <QtGui/QHeaderView>
#include <QtGui/QMenu>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtGui/QAction>
#include <QtGui/QMouseEvent>
#include <QtGui/QApplication>
#include <QtGui/QInputDialog>
#include <QtGui/QFileDialog>
#include <QtCore/QtDebug>
#include <QtGui/QHeaderView>
#include <QtGui/QInputDialog>
#include <QtGui/QMenu>
#include <QtGui/QMouseEvent>
#include <QtGui/QUndoStack>
namespace SharedTools {
......@@ -308,14 +312,14 @@ void ResourceView::findSamePlacePostDeletionModelIndex(int &row, QModelIndex &pa
EntryBackup * ResourceView::removeEntry(const QModelIndex &index)
{
Q_ASSERT(m_qrcModel != NULL);
QTC_ASSERT(m_qrcModel, return 0);
return m_qrcModel->removeEntry(index);
}
void ResourceView::addFiles(int prefixIndex, const QStringList &fileNames, int cursorFile,
int &firstFile, int &lastFile)
{
Q_ASSERT(m_qrcModel != NULL);
QTC_ASSERT(m_qrcModel, return);
m_qrcModel->addFiles(prefixIndex, fileNames, cursorFile, firstFile, lastFile);
// Expand prefix node
......@@ -327,11 +331,11 @@ void ResourceView::addFiles(int prefixIndex, const QStringList &fileNames, int c
void ResourceView::removeFiles(int prefixIndex, int firstFileIndex, int lastFileIndex)
{
Q_ASSERT((prefixIndex >= 0) && (prefixIndex < m_qrcModel->rowCount(QModelIndex())));
QTC_ASSERT(prefixIndex >= 0 && prefixIndex < m_qrcModel->rowCount(QModelIndex()), return);
const QModelIndex prefixModelIndex = m_qrcModel->index(prefixIndex, 0, QModelIndex());
Q_ASSERT(prefixModelIndex != QModelIndex());
Q_ASSERT((firstFileIndex >= 0) && (firstFileIndex < m_qrcModel->rowCount(prefixModelIndex)));
Q_ASSERT((lastFileIndex >= 0) && (lastFileIndex < m_qrcModel->rowCount(prefixModelIndex)));
QTC_ASSERT(prefixModelIndex != QModelIndex(), return);
QTC_ASSERT(firstFileIndex >= 0 && firstFileIndex < m_qrcModel->rowCount(prefixModelIndex), return);
QTC_ASSERT(lastFileIndex >= 0 && lastFileIndex < m_qrcModel->rowCount(prefixModelIndex), return);
for (int i = lastFileIndex; i >= firstFileIndex; i--) {
const QModelIndex index = m_qrcModel->index(i, 0, prefixModelIndex);
......@@ -568,7 +572,7 @@ QString ResourceView::getCurrentValue(NodeProperty property) const
case AliasProperty: return currentAlias();
case PrefixProperty: return currentPrefix();
case LanguageProperty: return currentLanguage();
default: Q_ASSERT(false); return QString(); // Kill warning
default: QTC_ASSERT(false, /**/); return QString(); // Kill warning
}
}
......@@ -579,7 +583,7 @@ void ResourceView::changeValue(const QModelIndex &nodeIndex, NodeProperty proper
case AliasProperty: m_qrcModel->changeAlias(nodeIndex, value); return;
case PrefixProperty: m_qrcModel->changePrefix(nodeIndex, value); return;
case LanguageProperty: m_qrcModel->changeLang(nodeIndex, value); return;
default: Q_ASSERT(false);
default: QTC_ASSERT(false, /**/);
}
}
......
......@@ -92,7 +92,7 @@ bool ModifyPropertyCommand::mergeWith(const QUndoCommand * command)
{
const ModifyPropertyCommand * const brother
= dynamic_cast<const ModifyPropertyCommand *>(command);
if (command == NULL || m_property != brother->m_property)
if (command == 0 || m_property != brother->m_property)
return false;
// Choose older command (this) and forgot the other
......@@ -101,7 +101,7 @@ bool ModifyPropertyCommand::mergeWith(const QUndoCommand * command)
void ModifyPropertyCommand::undo()
{
Q_ASSERT(m_view != NULL);
QTC_ASSERT(m_view, return);
// Save current text in m_after for redo()
m_after = m_view->getCurrentValue(m_property);
......@@ -117,12 +117,12 @@ void ModifyPropertyCommand::redo()
return;
// Bring back text before undo
Q_ASSERT(m_view != NULL);
QTC_ASSERT(m_view, return);
m_view->changeValue(makeIndex(), m_property, m_after);
}
RemoveEntryCommand::RemoveEntryCommand(ResourceView *view, const QModelIndex &index)
: ModelIndexViewCommand(view), m_entry(NULL), m_isExpanded(true)
: ModelIndexViewCommand(view), m_entry(0), m_isExpanded(true)
{
storeIndex(index);
}
......@@ -142,9 +142,9 @@ void RemoveEntryCommand::redo()
void RemoveEntryCommand::undo()
{
if (m_entry != NULL) {
if (m_entry == 0) {
m_entry->restore();
Q_ASSERT(m_view != NULL);
QTC_ASSERT(m_view != 0, return);
const QModelIndex index = makeIndex();
m_view->setExpanded(index, m_isExpanded);
m_view->setCurrentIndex(index);
......@@ -155,7 +155,7 @@ void RemoveEntryCommand::undo()
void RemoveEntryCommand::freeEntry()
{
delete m_entry;
m_entry = NULL;
m_entry = 0;
}
AddFilesCommand::AddFilesCommand(ResourceView *view, int prefixIndex, int cursorFileIndex,
......
......@@ -34,6 +34,8 @@
#ifndef WRAP_HELPERS_H
#define WRAP_HELPERS_H
#include <utils/qtcassert.h>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QtScript/QScriptValue>
......@@ -87,7 +89,7 @@ template <class Wrapper, class Wrapped>
Wrapped * (Wrapper::*wrappedAccessor) () const)
{
Wrapped *wrapped = wrappedFromScriptValue(context->thisObject(), wrappedAccessor);
Q_ASSERT(wrapped);
QTC_ASSERT(wrapped, return 0);
return wrapped;
}
......@@ -314,7 +316,7 @@ static void scriptValueToQObject(const QScriptValue &sv, SomeQObject * &p)
{
QObject *qObject = sv.toQObject();
p = qobject_cast<SomeQObject*>(qObject);
Q_ASSERT(p);
QTC_ASSERT(p, return);
}
// Register a QObject-derived class which has Q_DECLARE_METATYPE(Ptr*)
......
......@@ -32,6 +32,9 @@
***************************************************************************/
#include "CppDocument.h"
#include <utils/qtcassert.h>
#include <Control.h>
#include <TranslationUnit.h>
#include <DiagnosticClient.h>
......@@ -270,7 +273,7 @@ bool Document::parse(ParseMode mode)
void Document::check()
{
Q_ASSERT(! _globalNamespace);
QTC_ASSERT(!_globalNamespace, return);
Semantic semantic(_control);
......
......@@ -34,6 +34,8 @@
#include "OverviewModel.h"
#include "Overview.h"
#include <utils/qtcassert.h>
#include <Scope.h>
#include <Semantic.h>
#include <Literals.h>
......@@ -81,13 +83,13 @@ QModelIndex OverviewModel::index(int row, int column, const QModelIndex &parent)
return createIndex(row, column, symbol);
} else {
Symbol *parentSymbol = static_cast<Symbol *>(parent.internalPointer());
Q_ASSERT(parentSymbol != 0);
QTC_ASSERT(parentSymbol, return QModelIndex());
ScopedSymbol *scopedSymbol = parentSymbol->asScopedSymbol();
Q_ASSERT(scopedSymbol != 0);
QTC_ASSERT(scopedSymbol, return QModelIndex());
Scope *scope = scopedSymbol->members();
Q_ASSERT(scope != 0);
QTC_ASSERT(scope, return QModelIndex());
return createIndex(row, 0, scope->symbolAt(row));
}
......@@ -124,12 +126,12 @@ int OverviewModel::rowCount(const QModelIndex &parent) const
if (!parent.parent().isValid() && parent.row() == 0) // account for no symbol item
return 0;
Symbol *parentSymbol = static_cast<Symbol *>(parent.internalPointer());
Q_ASSERT(parentSymbol != 0);
QTC_ASSERT(parentSymbol, return 0);
if (ScopedSymbol *scopedSymbol = parentSymbol->asScopedSymbol()) {
if (!scopedSymbol->isFunction()) {
Scope *parentScope = scopedSymbol->members();
Q_ASSERT(parentScope != 0);
QTC_ASSERT(parentScope, return 0);
return parentScope->symbolCount();
}
......
......@@ -45,12 +45,14 @@
#include <TypeVisitor.h>
#include <NameVisitor.h>
#include <QList>
#include <QtDebug>
#include <utils/qtcassert.h>
#include <QtCore/QList>
#include <QtCore/QtDebug>
using namespace CPlusPlus;
namespace {
namespace {
typedef QList< QPair<Name *, FullySpecifiedType> > Substitution;
......@@ -98,7 +100,7 @@ protected:
// types
virtual void visit(PointerToMemberType * /*ty*/)
{
Q_ASSERT(0);
QTC_ASSERT(false, /**/);
}
virtual void visit(PointerType *ty)
......@@ -150,32 +152,32 @@ protected:
{ /* nothing to do*/ }
virtual void visit(Namespace *)
{ Q_ASSERT(0); }
{ QTC_ASSERT(false, /**/); }
virtual void visit(Class *)
{ Q_ASSERT(0); }
{ QTC_ASSERT(false, /**/); }
virtual void visit(Enum *)
{ Q_ASSERT(0); }
{ QTC_ASSERT(false, /**/); }
// names
virtual void visit(NameId *)
{ Q_ASSERT(0); }
{ QTC_ASSERT(false, /**/); }
virtual void visit(TemplateNameId *)
{ Q_ASSERT(0); }
{ QTC_ASSERT(false, /**/); }
virtual void visit(DestructorNameId *)
{ Q_ASSERT(0); }
{ QTC_ASSERT(false, /**/); }
virtual void visit(OperatorNameId *)
{ Q_ASSERT(0); }
{ QTC_ASSERT(false, /**/); }
virtual void visit(ConversionNameId *)
{ Q_ASSERT(0); }
{ QTC_ASSERT(false, /**/); }
virtual void visit(QualifiedNameId *)
{ Q_ASSERT(0); }
{ QTC_ASSERT(false, /**/); }
};
} // end of anonymous namespace
......
......@@ -52,11 +52,14 @@
#include "pp-environment.h"
#include "pp.h"
#include <utils/qtcassert.h>
#include <cstring>
using namespace CPlusPlus;
Environment::Environment ()
Environment::Environment()
: currentLine(0),
hide_next(false),
_macros(0),
......@@ -67,7 +70,7 @@ Environment::Environment ()
{
}
Environment::~Environment ()
Environment::~Environment()
{
if (_macros) {
qDeleteAll(firstMacro(), lastMacro());
......@@ -78,15 +81,19 @@ Environment::~Environment ()
free(_hash);
}
unsigned Environment::macroCount () const
{ return _macro_count + 1; }
unsigned Environment::macroCount() const
{
return _macro_count + 1;
}
Macro *Environment::macroAt (unsigned index) const
{ return _macros[index]; }
Macro *Environment::macroAt(unsigned index) const
{
return _macros[index];
}
Macro *Environment::bind(const Macro &__macro)
{
Q_ASSERT(! __macro.name.isEmpty());
QTC_ASSERT(! __macro.name.isEmpty(), return 0);
Macro *m = new Macro (__macro);
m->hashcode = hash_code(m->name);
......
......@@ -33,6 +33,8 @@
#include "classnamevalidatinglineedit.h"
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QRegExp>
......@@ -53,7 +55,7 @@ ClassNameValidatingLineEditPrivate:: ClassNameValidatingLineEditPrivate() :
m_namespaceDelimiter(QLatin1String("::")),
m_namespacesEnabled(false)
{
Q_ASSERT(m_nameRegexp.isValid());
QTC_ASSERT(m_nameRegexp.isValid(), return);
}
// --------------------- ClassNameValidatingLineEdit
......@@ -113,7 +115,7 @@ QString ClassNameValidatingLineEdit::createClassName(const QString &name)
// Remove spaces and convert the adjacent characters to uppercase
QString className = name;
QRegExp spaceMatcher(QLatin1String(" +(\\w)"), Qt::CaseSensitive, QRegExp::RegExp2);
Q_ASSERT(spaceMatcher.isValid());
QTC_ASSERT(spaceMatcher.isValid(), /**/);
int pos;
while ((pos = spaceMatcher.indexIn(className)) != -1) {
className.replace(pos, spaceMatcher.matchedLength(),
......
......@@ -32,6 +32,7 @@
***************************************************************************/
#include "filenamevalidatinglineedit.h"
#include "qtcassert.h"
#include <QtCore/QRegExp>
#include <QtCore/QDebug>
......@@ -46,7 +47,7 @@ static const QRegExp &windowsDeviceNoSubDirPattern()
{
static const QRegExp rc(QLatin1String("CON|AUX|PRN|COM1|COM2|LPT1|LPT2|NUL"),
Qt::CaseInsensitive);
Q_ASSERT(rc.isValid());
QTC_ASSERT(rc.isValid(), return rc);
return rc;
}
......@@ -54,7 +55,7 @@ static const QRegExp &windowsDeviceSubDirPattern()
{
static const QRegExp rc(QLatin1String(".*[/\\\\]CON|.*[/\\\\]AUX|.*[/\\\\]PRN|.*[/\\\\]COM1|.*[/\\\\]COM2|.*[/\\\\]LPT1|.*[/\\\\]LPT2|.*[/\\\\]NUL"),
Qt::CaseInsensitive);
Q_ASSERT(rc.isValid());
QTC_ASSERT(rc.isValid(), return rc);
return rc;
}
......
......@@ -32,18 +32,20 @@
***************************************************************************/
#include "pathchooser.h"
#include "basevalidatinglineedit.h"
#include <QtGui/QLineEdit>
#include <QtGui/QHBoxLayout>
#include <QtGui/QToolButton>
#include <QtGui/QFileDialog>
#include <QtGui/QDesktopServices>
#include "basevalidatinglineedit.h"
#include "qtcassert.h"
#include <QtCore/QFileInfo>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QSettings>
#include <QtCore/QDebug>
#include <QtGui/QDesktopServices>
#include <QtGui/QFileDialog>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QToolButton>
namespace Core {
namespace Utils {
......@@ -71,7 +73,7 @@ PathValidatingLineEdit::PathValidatingLineEdit(PathChooser *chooser, QWidget *pa
BaseValidatingLineEdit(parent),
m_chooser(chooser)
{
Q_ASSERT(chooser != NULL);
QTC_ASSERT(chooser, return);
}
bool PathValidatingLineEdit::validate(const QString &value, QString *errorMessage) const
......
......@@ -34,6 +34,8 @@
#ifndef QTC_ASSERT_H
#define QTC_ASSERT_H
#include <QtCore/QDebug>
#ifdef Q_OS_UNIX
#define QTC_ASSERT(cond, action) \
if(cond){}else{qDebug()<<"ASSERTION"<<#cond<<"FAILED"<<__FILE__<<__LINE__;action;}
......
......@@ -32,6 +32,7 @@
***************************************************************************/
#include "bookmarkmanager.h"
#include "bookmark.h"
#include "bookmarksplugin.h"
#include "bookmarks_global.h"
......@@ -41,12 +42,14 @@