diff --git a/installer/qinstaller.cpp b/installer/qinstaller.cpp
index b0b4cbff77ecfba6f3e2988712f93938d2e2f825..9ccaa53850cccc52cc6348db69326e3f94d7029f 100644
--- a/installer/qinstaller.cpp
+++ b/installer/qinstaller.cpp
@@ -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);
diff --git a/shared/cpaster/cgi.cpp b/shared/cpaster/cgi.cpp
index 2e94dc96b0230ff877fcce8648ff73bf59ece381..6e8ecd1404ca491f1ee2a41b3ea490e0ae1efa52 100644
--- a/shared/cpaster/cgi.cpp
+++ b/shared/cpaster/cgi.cpp
@@ -45,7 +45,7 @@ QString CGI::encodeURL(const QString &rawText)
     enc.reserve(utf.length()); // Make sure we at least have space for a normal US-ASCII URL
     
     QByteArray::const_iterator it = utf.constBegin();
-    while(it != utf.constEnd()) {
+    while (it != utf.constEnd()) {
         char ch = *it;
         if (('A' <= ch && ch <= 'Z')
             || ('a' <= ch && ch <= 'z')
@@ -54,7 +54,7 @@ QString CGI::encodeURL(const QString &rawText)
         else if (ch == ' ')
             enc.append('+');
         else {
-            switch(ch) {
+            switch (ch) {
             case '-': case '_':
             case '(': case ')':
             case '.': case '!':
@@ -80,15 +80,15 @@ QString CGI::decodeURL(const QString &urlText)
 {
     QByteArray dec;
     QString::const_iterator it = urlText.constBegin();
-    while(it != urlText.constEnd()) {
+    while (it != urlText.constEnd()) {
         ushort ch = (*it).unicode();
-        switch(ch) {
+        switch (ch) {
         case '%':
             {
                 char c1 = char(0x00ff & (*(++it)).unicode());
                 char c2 = char(0x00ff & (*(++it)).unicode());
                 ushort v = 0;
-                if('A' <= c1 && c1 <= 'Z')
+                if ('A' <= c1 && c1 <= 'Z')
                     v = c1 - 'A' + 10;
                 else if ('a' <= c1 && c1 <= 'z')
                     v = c1 - 'a' + 10;
@@ -97,7 +97,7 @@ QString CGI::decodeURL(const QString &urlText)
                 else
                     continue; // Malformed URL!
                 v <<= 4; // c1 was MSB half
-                if('A' <= c2 && c2 <= 'Z')
+                if ('A' <= c2 && c2 <= 'Z')
                     v |= c2 - 'A' + 10;
                 else if ('a' <= c2 && c2 <= 'z')
                     v |= c2 - 'a' + 10;
@@ -123,7 +123,7 @@ QString CGI::decodeURL(const QString &urlText)
 // -------------------------------------------------------------------------------------------------
 inline const char *unicodeToHTML(ushort unicode_char)
 {
-    switch(unicode_char) {
+    switch (unicode_char) {
     // Latin -------------------------------
     case 0x0022: return "quot";    // (34  ) quotation mark = APL quote
     case 0x0026: return "amp";     // (38  ) ampersand
diff --git a/shared/cpaster/splitter.cpp b/shared/cpaster/splitter.cpp
index 08ec626f625a83352141e92c87baed8d6f62bb6d..22ccf1d99012fc6553cd5effa9551821c58da85c 100644
--- a/shared/cpaster/splitter.cpp
+++ b/shared/cpaster/splitter.cpp
@@ -66,10 +66,8 @@ FileDataList splitDiffToFiles(const QByteArray &data)
     // The algorithm works like this:
     // On the first match we only get the filename of the first patch part
     // On the second match (if any) we get the diff content, and the name of the next file patch
-    //
     
-    
-    while(-1 != (splitIndex = splitExpr.indexIn(strData,splitIndex))) {
+    while (-1 != (splitIndex = splitExpr.indexIn(strData,splitIndex))) {
         if (!filename.isEmpty()) {
             QString content = strData.mid(previousSplit, splitIndex - previousSplit);
             ret.append(FileData(filename, content.toLatin1()));
diff --git a/shared/cpaster/view.cpp b/shared/cpaster/view.cpp
index ca5bd270eb2d46aa3dc7ff6521ab2e99d442bbf8..6c37defe36b99cf5211570d5b3dcf31a1d046664 100644
--- a/shared/cpaster/view.cpp
+++ b/shared/cpaster/view.cpp
@@ -125,7 +125,7 @@ QString View::getComment()
 QByteArray View::getContent()
 {
     QByteArray newContent;
-    for(int i = 0; i < m_ui.uiPatchList->count(); ++i) {
+    for (int i = 0; i < m_ui.uiPatchList->count(); ++i) {
         QListWidgetItem *item = m_ui.uiPatchList->item(i);
         if (item->checkState() != Qt::Unchecked)
             newContent += m_parts.at(i).content;
@@ -159,7 +159,7 @@ int View::show(const QString &user, const QString &description, const QString &c
     QByteArray content;
     m_parts = parts;
     m_ui.uiPatchList->clear();
-    foreach(const FileData part, parts) {
+    foreach (const FileData part, parts) {
         QListWidgetItem *itm = new QListWidgetItem(part.filename, m_ui.uiPatchList);
         itm->setCheckState(Qt::Checked);
         itm->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
diff --git a/shared/cplusplus/Control.cpp b/shared/cplusplus/Control.cpp
index c994dbab9a276f6885e121f0176cac8ff44a1972..a486dfdb9408b9b7544c03d4a19e3cba9a287087 100644
--- a/shared/cplusplus/Control.cpp
+++ b/shared/cplusplus/Control.cpp
@@ -511,6 +511,12 @@ Identifier *Control::findOrInsertIdentifier(const char *chars)
     return findOrInsertIdentifier(chars, length);
 }
 
+Control::IdentifierIterator Control::firstIdentifier() const
+{ return d->identifiers.begin(); }
+
+Control::IdentifierIterator Control::lastIdentifier() const
+{ return d->identifiers.end(); }
+
 StringLiteral *Control::findOrInsertStringLiteral(const char *chars, unsigned size)
 { return d->stringLiterals.findOrInsertLiteral(chars, size); }
 
diff --git a/shared/cplusplus/Control.h b/shared/cplusplus/Control.h
index fa7b4faa50256d43202acaa0591600ce1eb64ebe..bd4b204843f3ae215b0db7138f34d5c25e336e8e 100644
--- a/shared/cplusplus/Control.h
+++ b/shared/cplusplus/Control.h
@@ -151,6 +151,11 @@ public:
     Identifier *findOrInsertIdentifier(const char *chars, unsigned size);
     Identifier *findOrInsertIdentifier(const char *chars);
 
+    typedef const Identifier *const *IdentifierIterator;
+
+    IdentifierIterator firstIdentifier() const;
+    IdentifierIterator lastIdentifier() const;
+
     StringLiteral *findOrInsertStringLiteral(const char *chars, unsigned size);
     StringLiteral *findOrInsertStringLiteral(const char *chars);
 
diff --git a/shared/designerintegrationv2/formresizer.cpp b/shared/designerintegrationv2/formresizer.cpp
index 3b44599d7efb4a0518d3462908e748a19d5d11e3..156b8e718acaa34cecef5de4eaabce0c3bcca26c 100644
--- a/shared/designerintegrationv2/formresizer.cpp
+++ b/shared/designerintegrationv2/formresizer.cpp
@@ -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;
diff --git a/shared/help/helpviewer.cpp b/shared/help/helpviewer.cpp
index d542e4996f56592719b507ec1c77dbc604db52ee..9b80e99cd8437b1b5507478de6aa2fa106e7ca54 100644
--- a/shared/help/helpviewer.cpp
+++ b/shared/help/helpviewer.cpp
@@ -409,7 +409,7 @@ QVariant HelpViewer::loadResource(int type, const QUrl &name)
 
 void HelpViewer::openLinkInNewTab()
 {
-    if(lastAnchor.isEmpty())
+    if (lastAnchor.isEmpty())
         return;
 
     parentWidget->setSourceInNewTab(QUrl(lastAnchor));
diff --git a/shared/indenter/constants.cpp b/shared/indenter/constants.cpp
index 2339ceb693872ff4364c12d610b1e25bf93c33e5..120ebdccb2253a75474e504d2d7e4c3fa715c3cf 100644
--- a/shared/indenter/constants.cpp
+++ b/shared/indenter/constants.cpp
@@ -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);
 }
diff --git a/shared/indenter/test/main.cpp b/shared/indenter/test/main.cpp
index 701f66987c010968d53bef1fa80d7410d2502be8..e9c9396197a476794c5bbd03d2f0ad56d9a02cf1 100644
--- a/shared/indenter/test/main.cpp
+++ b/shared/indenter/test/main.cpp
@@ -174,7 +174,7 @@ int main(int argc, char **argv)
         return 1;
     }
 
-    foreach(QString fileName, fileNames)
+    foreach (const QString &fileName, fileNames)
         if (const int rc = format(fileName))
             return rc;
 
diff --git a/shared/proparser/procommandmanager.cpp b/shared/proparser/procommandmanager.cpp
index a6b61f4a3fbe34666fd3fd179494ddbf2d3e12fe..99fc30256379c092486e6721ea40d5abe48af479 100644
--- a/shared/proparser/procommandmanager.cpp
+++ b/shared/proparser/procommandmanager.cpp
@@ -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);
diff --git a/shared/proparser/proeditor.cpp b/shared/proparser/proeditor.cpp
index 02287b06ab102caaf044e14adac3ce28c8ddc0bb..93adb12493eee6946266417efa298d4d16e39258 100644
--- a/shared/proparser/proeditor.cpp
+++ b/shared/proparser/proeditor.cpp
@@ -139,7 +139,7 @@ bool ProEditor::eventFilter(QObject *, QEvent *event)
     if (event->type() == QEvent::ShortcutOverride) {
         QKeyEvent *k = static_cast<QKeyEvent*>(event);
         if (k->modifiers() == Qt::ControlModifier) {
-            switch(k->key()) {
+            switch (k->key()) {
                 case Qt::Key_X:
                     cut(); return true;
                 case Qt::Key_C:
@@ -168,11 +168,8 @@ void ProEditor::updatePasteAction()
     bool pasteEnabled = false;
 
     const QMimeData *data = QApplication::clipboard()->mimeData();
-    if (data) {
-        if (data->hasFormat(QLatin1String("application/x-problock"))) {
-            pasteEnabled = true;
-        }
-    }
+    if (data && data->hasFormat(QLatin1String("application/x-problock")))
+        pasteEnabled = true;
 
     m_pasteAction->setEnabled(pasteEnabled);
 }
diff --git a/shared/proparser/proeditormodel.cpp b/shared/proparser/proeditormodel.cpp
index d0f28f68688c89c43cc30972ca075f2bf58399ac..a929c7ab88d781526f11da4827ed78af41fa54f4 100644
--- a/shared/proparser/proeditormodel.cpp
+++ b/shared/proparser/proeditormodel.cpp
@@ -732,13 +732,10 @@ bool ProEditorModel::insertItem(ProItem *item, int row, const QModelIndex &paren
 
 void ProEditorModel::markProFileModified(QModelIndex index)
 {
-    while(index.isValid())
-    {        
-        if( proItem(index)->kind() == ProItem::BlockKind)
-        {
+    while (index.isValid()) {        
+        if (proItem(index)->kind() == ProItem::BlockKind) {
             ProBlock * block = proBlock(index);
-            if(block->blockKind() == ProBlock::ProFileKind)
-            {
+            if (block->blockKind() == ProBlock::ProFileKind) {
                 ProFile * file = static_cast<ProFile *>(block);
                 file->setModified(true);
                 return;
@@ -791,9 +788,9 @@ QString ProEditorModel::expressionToString(ProBlock *block, bool display) const
 {
     QString result;
     QList<ProItem*> items = block->items();
-    for(int i=0; i<items.count(); ++i) {
+    for (int i = 0; i < items.count(); ++i) {
         ProItem *item = items.at(i);
-        switch(item->kind()) {
+        switch (item->kind()) {
             case ProItem::FunctionKind: {
                 ProFunction *v = static_cast<ProFunction*>(item);
                 result += v->text();
@@ -808,14 +805,16 @@ QString ProEditorModel::expressionToString(ProBlock *block, bool display) const
                 } else {
                     result += v->text();
                 }
-                break; }
+                break;
+            }
             case ProItem::OperatorKind: {
                 ProOperator *v = static_cast<ProOperator*>(item);
                 if (v->operatorKind() == ProOperator::NotOperator)
                     result += QLatin1Char('!');
                 else
                     result += QLatin1Char('|');
-                break; }
+                break;
+            }
             case ProItem::ValueKind:
             case ProItem::BlockKind:
                 break; // ### unhandled
@@ -847,7 +846,7 @@ QList<ProItem *> ProEditorModel::stringToExpression(const QString &exp) const
     bool c = false;
 
     QString tmpstr;
-    for (int i=0; i<exp.length(); ++i) {
+    for (int i = 0; i < exp.length(); ++i) {
         QChar tmpchar = exp.at(i);
         if (tmpchar == '(') ++p;
         else if (tmpchar == ')') --p;
diff --git a/shared/proparser/profileevaluator.cpp b/shared/proparser/profileevaluator.cpp
index c50de16fecabe94caa3c04e3ad88c4d386fc0613..1935efa2fdf3c9d585c7a5b6d6599d420c1bed1c 100644
--- a/shared/proparser/profileevaluator.cpp
+++ b/shared/proparser/profileevaluator.cpp
@@ -35,6 +35,8 @@
 #include "proparserutils.h"
 #include "proitems.h"
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/QByteArray>
 #include <QtCore/QDebug>
 #include <QtCore/QDir>
@@ -332,7 +334,7 @@ void ProFileEvaluator::Private::insertOperator(const char op)
     updateItem();
 
     ProOperator::OperatorKind opkind;
-    switch(op) {
+    switch (op) {
         case '!':
             opkind = ProOperator::NotOperator;
             break;
@@ -532,21 +534,21 @@ bool ProFileEvaluator::Private::visitEndProFile(ProFile * pro)
             evaluateFile(mkspecDirectory + "/features/default_post.prf", &ok);
 
             QStringList processed;
-            while(1) {
+            while (1) {
                 bool finished = true;
                 QStringList configs = values("CONFIG");
-                for(int i = configs.size()-1; i >= 0; --i) {
+                for (int i = configs.size()-1; i >= 0; --i) {
                     const QString config = configs[i].toLower();
-                    if(!processed.contains(config)) {
+                    if (!processed.contains(config)) {
                         processed.append(config);
                         evaluateFile(mkspecDirectory + "/features/" + config + ".prf", &ok);
-                        if(ok) {
+                        if (ok) {
                             finished = false;
                             break;
                         }
                     }
                 }
-                if(finished)
+                if (finished)
                     break;
             }
         }
@@ -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);
diff --git a/shared/proparser/proparserutils.h b/shared/proparser/proparserutils.h
index 8c5cb3aaabca67d9beec918ef38100c5f542c9dd..82941e31c1be4a7795004c14bbe350199db84e90 100644
--- a/shared/proparser/proparserutils.h
+++ b/shared/proparser/proparserutils.h
@@ -173,41 +173,41 @@ static QStringList split_arg_list(QString params)
     const QChar *params_data = params.data();
     const int params_len = params.length();
     int last = 0;
-    while(last < params_len && ((params_data+last)->unicode() == SPACE
+    while (last < params_len && ((params_data+last)->unicode() == SPACE
                                 /*|| (params_data+last)->unicode() == TAB*/))
         ++last;
-    for(int x = last, parens = 0; x <= params_len; x++) {
+    for (int x = last, parens = 0; x <= params_len; x++) {
         unicode = (params_data+x)->unicode();
-        if(x == params_len) {
-            while(x && (params_data+(x-1))->unicode() == SPACE)
+        if (x == params_len) {
+            while (x && (params_data+(x-1))->unicode() == SPACE)
                 --x;
             QString mid(params_data+last, x-last);
-            if(quote) {
-                if(mid[0] == quote && mid[(int)mid.length()-1] == quote)
+            if (quote) {
+                if (mid[0] == quote && mid[(int)mid.length()-1] == quote)
                     mid = mid.mid(1, mid.length()-2);
                 quote = 0;
             }
             args << mid;
             break;
         }
-        if(unicode == LPAREN) {
+        if (unicode == LPAREN) {
             --parens;
-        } else if(unicode == RPAREN) {
+        } else if (unicode == RPAREN) {
             ++parens;
-        } else if(quote && unicode == quote) {
+        } else if (quote && unicode == quote) {
             quote = 0;
-        } else if(!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) {
+        } else if (!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) {
             quote = unicode;
-        } else if(!parens && !quote && unicode == COMMA) {
+        } else if (!parens && !quote && unicode == COMMA) {
             QString mid = params.mid(last, x - last).trimmed();
             args << mid;
             last = x+1;
-            while(last < params_len && ((params_data+last)->unicode() == SPACE
+            while (last < params_len && ((params_data+last)->unicode() == SPACE
                                         /*|| (params_data+last)->unicode() == TAB*/))
                 ++last;
         }
     }
-    for(int i = 0; i < args.count(); i++)
+    for (int i = 0; i < args.count(); i++)
         unquote(&args[i]);
     return args;
 }
@@ -227,22 +227,22 @@ static QStringList split_value_list(const QString &vals, bool do_semicolon=false
 
     const QChar *vals_data = vals.data();
     const int vals_len = vals.length();
-    for(int x = 0, parens = 0; x < vals_len; x++) {
+    for (int x = 0, parens = 0; x < vals_len; x++) {
         QChar c = vals_data[x];
         if (x != vals_len-1 && c == BACKSLASH &&
            vals_data[x+1].unicode() == '\'' || vals_data[x+1] == DOUBLEQUOTE) {
             build += vals_data[x++]; // get that 'escape'
         } else if (!quote.isEmpty() && c == quote.top()) {
             quote.pop();
-        } else if(c == SINGLEQUOTE || c == DOUBLEQUOTE) {
+        } else if (c == SINGLEQUOTE || c == DOUBLEQUOTE) {
             quote.push(c);
-        } else if(c == RPAREN) {
+        } else if (c == RPAREN) {
             --parens;
-        } else if(c == LPAREN) {
+        } else if (c == LPAREN) {
             ++parens;
         }
 
-        if(!parens && quote.isEmpty() && ((do_semicolon && c == SEMICOLON) ||
+        if (!parens && quote.isEmpty() && ((do_semicolon && c == SEMICOLON) ||
                                           vals_data[x] == Option::field_sep)) {
             ret << build;
             build.clear();
@@ -250,7 +250,7 @@ static QStringList split_value_list(const QString &vals, bool do_semicolon=false
             build += vals_data[x];
         }
     }
-    if(!build.isEmpty())
+    if (!build.isEmpty())
         ret << build;
     return ret;
 }
@@ -262,7 +262,7 @@ static QStringList qmake_mkspec_paths()
     QByteArray qmakepath = qgetenv("QMAKEPATH");
     if (!qmakepath.isEmpty()) {
         const QStringList lst = splitPathList(QString::fromLocal8Bit(qmakepath));
-        for(QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it)
+        for (QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it)
             ret << ((*it) + concat);
     }
     ret << QLibraryInfo::location(QLibraryInfo::DataPath) + concat;
diff --git a/shared/proparser/prowriter.cpp b/shared/proparser/prowriter.cpp
index 0f215fd79c4ca2df140cfe45877ddacdb9637ed0..98787294ce48872338e10bd4c929c92e2c5598b2 100644
--- a/shared/proparser/prowriter.cpp
+++ b/shared/proparser/prowriter.cpp
@@ -137,7 +137,7 @@ void ProWriter::writeBlock(ProBlock *block, const QString &indent)
     if (block->blockKind() & ProBlock::VariableKind) {
         ProVariable *v = static_cast<ProVariable*>(block);
         m_out << v->variable();
-        switch(v->variableOperator()) {
+        switch (v->variableOperator()) {
             case ProVariable::AddOperator:
                 m_out << QLatin1String(" += "); break;
             case ProVariable::RemoveOperator:
@@ -165,12 +165,12 @@ void ProWriter::writeBlock(ProBlock *block, const QString &indent)
     }
 
     QList<ProItem*> items = block->items();
-    for (int i=0; i<items.count(); ++i) {
+    for (int i = 0; i < items.count(); ++i) {
         m_writeState &= ~LastItem;
         m_writeState &= ~FirstItem;
         if (i == 0)
             m_writeState |= FirstItem;
-        if (i == (items.count()-1))
+        if (i == items.count() - 1)
             m_writeState |= LastItem;
         writeItem(items.at(i), newindent);
     }
diff --git a/shared/proparser/proxml.cpp b/shared/proparser/proxml.cpp
index 4b63fc255d3a659b44fbfb7ab7be4a60a28a1fe1..2416b3f6bc1dd235b26d34c5b8246aa45d54ca8a 100644
--- a/shared/proparser/proxml.cpp
+++ b/shared/proparser/proxml.cpp
@@ -104,7 +104,7 @@ QDomNode ProXmlParser::createItemNode(QDomDocument doc, ProItem *item) const
             tag = doc.createElement(QLatin1String("block"));
         }
 
-        foreach(ProItem *child, block->items()) {
+        foreach (ProItem *child, block->items()) {
             QDomNode childNode = createItemNode(doc, child);
             if (!childNode.isNull())
                 tag.appendChild(childNode);
diff --git a/shared/proparser/valueeditor.cpp b/shared/proparser/valueeditor.cpp
index 2208b0492e9ebbc6c4e5390dd1f31e7af9f8c421..638d7994a9224eee505152958bb51a6dccc673e2 100644
--- a/shared/proparser/valueeditor.cpp
+++ b/shared/proparser/valueeditor.cpp
@@ -131,7 +131,7 @@ void ValueEditor::initialize()
     connect(m_itemListWidget, SIGNAL(itemChanged(QListWidgetItem *)),
         this, SLOT(updateItemChanges(QListWidgetItem *)));
 
-    foreach(ProVariableInfo *varinfo, m_infomanager->variables()) {
+    foreach (ProVariableInfo *varinfo, m_infomanager->variables()) {
         m_varComboBox->addItem(varinfo->name(), varinfo->id());
     }
 
diff --git a/shared/qrceditor/resourcefile.cpp b/shared/qrceditor/resourcefile.cpp
index daf1946e53eb67ebc6b77bc6e1d70c34560ea227..f394f43f41ef0ea183c9a6af87bc83896e5e0471 100644
--- a/shared/qrceditor/resourcefile.cpp
+++ b/shared/qrceditor/resourcefile.cpp
@@ -33,13 +33,16 @@
 
 #include "resourcefile_p.h"
 
-#include <QtCore/QtAlgorithms>
-#include <QtCore/QFile>
-#include <QtCore/QTextStream>
+#include <utils/qtcassert.h>
+
 #include <QtCore/QCoreApplication>
+#include <QtCore/QDebug>
 #include <QtCore/QDir>
+#include <QtCore/QFile>
 #include <QtCore/QMimeData>
-#include <QtCore/QDebug>
+#include <QtCore/QtAlgorithms>
+#include <QtCore/QTextStream>
+
 #include <QtGui/QIcon>
 #include <QtGui/QImageReader>
 
@@ -109,14 +112,14 @@ bool ResourceFile::load()
         const QString language = relt.attribute(QLatin1String("lang"));
 
         const int idx = indexOfPrefix(prefix);
-        Prefix * p = NULL;
+        Prefix * p = 0;
         if (idx == -1) {
             p = new Prefix(prefix, language);
             m_prefix_list.append(p);
         } else {
             p = m_prefix_list[idx];
         }
-        Q_ASSERT(p != NULL);
+        QTC_ASSERT(p, return false);
 
         QDomElement felt = relt.firstChildElement(QLatin1String("file"));
         for (; !felt.isNull(); felt = felt.nextSiblingElement(QLatin1String("file"))) {
@@ -151,7 +154,7 @@ bool ResourceFile::save()
 
     const QStringList name_list = prefixList();
 
-    foreach (QString name, name_list) {
+    foreach (const QString &name, name_list) {
         FileList file_list;
         QString lang;
         foreach (Prefix *pref, m_prefix_list) {
@@ -164,7 +167,7 @@ bool ResourceFile::save()
         QDomElement relt = doc.createElement(QLatin1String("qresource"));
         root.appendChild(relt);
         relt.setAttribute(QLatin1String("prefix"), name);
-        if(!lang.isEmpty())
+        if (!lang.isEmpty())
             relt.setAttribute(QLatin1String("lang"), lang);
 
         foreach (const File *f, file_list) {
@@ -247,9 +250,9 @@ bool ResourceFile::isEmpty() const
 
 QStringList ResourceFile::fileList(int pref_idx) const
 {
-    Q_ASSERT((pref_idx >= 0) && (pref_idx < m_prefix_list.count()));
-    const FileList &abs_file_list = m_prefix_list.at(pref_idx)->file_list;
     QStringList result;
+    QTC_ASSERT(pref_idx >= 0 && pref_idx < m_prefix_list.count(), return result);
+    const FileList &abs_file_list = m_prefix_list.at(pref_idx)->file_list;
     foreach (const File *abs_file, abs_file_list)
         result.append(relativePath(abs_file->name));
     return result;
@@ -258,9 +261,9 @@ QStringList ResourceFile::fileList(int pref_idx) const
 void ResourceFile::addFile(int prefix_idx, const QString &file, int file_idx)
 {
     Prefix * const p = m_prefix_list[prefix_idx];
-    Q_ASSERT(p != NULL);
+    QTC_ASSERT(p, return);
     FileList &files = p->file_list;
-    Q_ASSERT((file_idx >= -1) && (file_idx <= files.size()));
+    QTC_ASSERT(file_idx >= -1 && file_idx <= files.size(), return);
     if (file_idx == -1)
         file_idx = files.size();
     files.insert(file_idx, new File(p, absolutePath(file)));
@@ -272,7 +275,7 @@ void ResourceFile::addPrefix(const QString &prefix, int prefix_idx)
     if (indexOfPrefix(fixed_prefix) != -1)
         return;
 
-    Q_ASSERT((prefix_idx >= -1) && (prefix_idx <= m_prefix_list.size()));
+    QTC_ASSERT(prefix_idx >= -1 && prefix_idx <= m_prefix_list.size(), return);
     if (prefix_idx == -1)
         prefix_idx = m_prefix_list.size();
     m_prefix_list.insert(prefix_idx, new Prefix(fixed_prefix));
@@ -280,7 +283,7 @@ void ResourceFile::addPrefix(const QString &prefix, int prefix_idx)
 
 void ResourceFile::removePrefix(int prefix_idx)
 {
-    Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count()));
+    QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return);
     Prefix * const p = m_prefix_list.at(prefix_idx);
     delete p;
     m_prefix_list.removeAt(prefix_idx);
@@ -288,39 +291,39 @@ void ResourceFile::removePrefix(int prefix_idx)
 
 void ResourceFile::removeFile(int prefix_idx, int file_idx)
 {
-    Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count()));
+    QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return);
     FileList &fileList = m_prefix_list[prefix_idx]->file_list;
-    Q_ASSERT((file_idx >= 0) && (file_idx < fileList.count()));
+    QTC_ASSERT(file_idx >= 0 && file_idx < fileList.count(), return);
     delete fileList.at(file_idx);
     fileList.removeAt(file_idx);
 }
 
 void ResourceFile::replacePrefix(int prefix_idx, const QString &prefix)
 {
-    Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count()));
+    QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return);
     m_prefix_list[prefix_idx]->name = fixPrefix(prefix);
 }
 
 void ResourceFile::replaceLang(int prefix_idx, const QString &lang)
 {
-    Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count()));
+    QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return);
     m_prefix_list[prefix_idx]->lang = lang;
 }
 
 void ResourceFile::replaceAlias(int prefix_idx, int file_idx, const QString &alias)
 {
-    Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count()));
+    QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return);
     FileList &fileList = m_prefix_list.at(prefix_idx)->file_list;
-    Q_ASSERT((file_idx >= 0) && (file_idx < fileList.count()));
+    QTC_ASSERT(file_idx >= 0 && file_idx < fileList.count(), return);
     fileList[file_idx]->alias = alias;
 }
 
 
 void ResourceFile::replaceFile(int pref_idx, int file_idx, const QString &file)
 {
-    Q_ASSERT((pref_idx >= 0) && (pref_idx < m_prefix_list.count()));
+    QTC_ASSERT(pref_idx >= 0 && pref_idx < m_prefix_list.count(), return);
     FileList &fileList = m_prefix_list.at(pref_idx)->file_list;
-    Q_ASSERT((file_idx >= 0) && (file_idx < fileList.count()));
+    QTC_ASSERT(file_idx >= 0 && file_idx < fileList.count(), return);
     fileList[file_idx]->name = file;
 }
 
@@ -336,7 +339,7 @@ int ResourceFile::indexOfPrefix(const QString &prefix) const
 
 int ResourceFile::indexOfFile(int pref_idx, const QString &file) const
 {
-    Q_ASSERT((pref_idx >= 0) && (pref_idx < m_prefix_list.count()));
+    QTC_ASSERT(pref_idx >= 0 && pref_idx < m_prefix_list.count(), return -1);
     Prefix * const p = m_prefix_list.at(pref_idx);
     File equalFile(p, absolutePath(file));
     return p->file_list.indexOf(&equalFile);
@@ -370,16 +373,16 @@ bool ResourceFile::contains(const QString &prefix, const QString &file) const
         return false;
     if (file.isEmpty())
         return true;
-    Q_ASSERT((pref_idx >= 0) && (pref_idx < m_prefix_list.count()));
+    QTC_ASSERT(pref_idx >= 0 && pref_idx < m_prefix_list.count(), return false);
     Prefix * const p = m_prefix_list.at(pref_idx);
-    Q_ASSERT(p != NULL);
+    QTC_ASSERT(p, return false);
     File equalFile(p, absolutePath(file));
     return p->file_list.contains(&equalFile);
 }
 
 bool ResourceFile::contains(int pref_idx, const QString &file) const
 {
-    Q_ASSERT((pref_idx >= 0) && (pref_idx < m_prefix_list.count()));
+    QTC_ASSERT(pref_idx >= 0 && pref_idx < m_prefix_list.count(), return false);
     Prefix * const p = m_prefix_list.at(pref_idx);
     File equalFile(p, absolutePath(file));
     return p->file_list.contains(&equalFile);
@@ -409,49 +412,49 @@ int ResourceFile::prefixCount() const
 
 QString ResourceFile::prefix(int idx) const
 {
-    Q_ASSERT((idx >= 0) && (idx < m_prefix_list.count()));
+    QTC_ASSERT((idx >= 0) && (idx < m_prefix_list.count()), return QString());
     return m_prefix_list.at(idx)->name;
 }
 
 QString ResourceFile::lang(int idx) const
 {
-    Q_ASSERT((idx >= 0) && (idx < m_prefix_list.count()));
+    QTC_ASSERT(idx >= 0 && idx < m_prefix_list.count(), return QString());
     return m_prefix_list.at(idx)->lang;
 }
 
 int ResourceFile::fileCount(int prefix_idx) const
 {
-    Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count()));
+    QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return 0);
     return m_prefix_list.at(prefix_idx)->file_list.size();
 }
 
 QString ResourceFile::file(int prefix_idx, int file_idx) const
 {
-    Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count()));
+    QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return QString());
     FileList &fileList = m_prefix_list.at(prefix_idx)->file_list;
-    Q_ASSERT((file_idx >= 0) && (file_idx < fileList.count()));
+    QTC_ASSERT(file_idx >= 0 && file_idx < fileList.count(), return QString());
     return fileList.at(file_idx)->name;
 }
 
 QString ResourceFile::alias(int prefix_idx, int file_idx) const
 {
-    Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count()));
+    QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return QString());
     FileList &fileList = m_prefix_list.at(prefix_idx)->file_list;
-    Q_ASSERT((file_idx >= 0) && (file_idx < fileList.count()));
+    QTC_ASSERT(file_idx >= 0 && file_idx < fileList.count(), return QString());
     return fileList.at(file_idx)->alias;
 }
 
 void * ResourceFile::prefixPointer(int prefixIndex) const
 {
-    Q_ASSERT((prefixIndex >= 0) && (prefixIndex < m_prefix_list.count()));
+    QTC_ASSERT(prefixIndex >= 0 && prefixIndex < m_prefix_list.count(), return 0);
     return m_prefix_list.at(prefixIndex);
 }
 
 void * ResourceFile::filePointer(int prefixIndex, int fileIndex) const
 {
-    Q_ASSERT((prefixIndex >= 0) && (prefixIndex < m_prefix_list.count()));
+    QTC_ASSERT(prefixIndex >= 0 && prefixIndex < m_prefix_list.count(), return 0);
     FileList &fileList = m_prefix_list.at(prefixIndex)->file_list;
-    Q_ASSERT((fileIndex >= 0) && (fileIndex < fileList.count()));
+    QTC_ASSERT(fileIndex >= 0 && fileIndex < fileList.count(), return 0);
     return fileList.at(fileIndex);
 }
 
@@ -497,28 +500,28 @@ QModelIndex ResourceModel::index(int row, int column, const QModelIndex &parent)
     if (column != 0)
         return QModelIndex();
 
-    void * internalPointer = NULL;
+    void * internalPointer = 0;
     if (parent.isValid()) {
         void * const pip = parent.internalPointer();
-        if (pip == NULL)
+        if (pip == 0)
             return QModelIndex();
 
         // File node
         Node * const node = reinterpret_cast<Node *>(pip);
         Prefix * const prefix = node->prefix();
-        Q_ASSERT(prefix != NULL);
-        if ((row < 0) || (row >= prefix->file_list.count()))
+        QTC_ASSERT(prefix, return QModelIndex());
+        if (row < 0 || row >= prefix->file_list.count())
             return QModelIndex();
         const int prefixIndex = m_resource_file.prefixPointerIndex(prefix);
         const int fileIndex = row;
         internalPointer = m_resource_file.filePointer(prefixIndex, fileIndex);
     } else {
         // Prefix node
-        if ((row < 0) || (row >= m_resource_file.prefixCount()))
+        if (row < 0 || row >= m_resource_file.prefixCount())
             return QModelIndex();
         internalPointer = m_resource_file.prefixPointer(row);
     }
-    Q_ASSERT(internalPointer != NULL);
+    QTC_ASSERT(internalPointer, return QModelIndex());
     return createIndex(row, 0, internalPointer);
 }
 
@@ -528,16 +531,16 @@ QModelIndex ResourceModel::parent(const QModelIndex &index) const
         return QModelIndex();
 
     void * const internalPointer = index.internalPointer();
-    if (internalPointer == NULL)
+    if (internalPointer == 0)
         return QModelIndex();
     Node * const node = reinterpret_cast<Node *>(internalPointer);
     Prefix * const prefix = node->prefix();
-    Q_ASSERT(prefix != NULL);
+    QTC_ASSERT(prefix, return QModelIndex());
     bool const isFileNode = (prefix != node);
 
     if (isFileNode) {
         const int row = m_resource_file.prefixPointerIndex(prefix);
-        Q_ASSERT(row >= 0);
+        QTC_ASSERT(row >= 0, return QModelIndex());
         return createIndex(row, 0, prefix);
     } else {
         return QModelIndex();
@@ -550,7 +553,7 @@ int ResourceModel::rowCount(const QModelIndex &parent) const
         void * const internalPointer = parent.internalPointer();
         Node * const node = reinterpret_cast<Node *>(internalPointer);
         Prefix * const prefix = node->prefix();
-        Q_ASSERT(prefix != NULL);
+        QTC_ASSERT(prefix, return 0);
         bool const isFileNode = (prefix != node);
 
         if (isFileNode) {
@@ -609,7 +612,7 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const
     Node * const node = reinterpret_cast<Node *>(internalPointer);
     Prefix const * const prefix = node->prefix();
     File const * const file = node->file();
-    Q_ASSERT(prefix != NULL);
+    QTC_ASSERT(prefix, return QVariant());
     bool const isFileNode = (prefix != node);
 
     QVariant result;
@@ -622,14 +625,14 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const
                 // Prefix node
                 stringRes = prefix->name;
                 const QString &lang = prefix->lang;
-                if(!lang.isEmpty())
+                if (!lang.isEmpty())
                     appendParenthesized(lang, stringRes);
             } else  {
                 // File node
-                Q_ASSERT(file != NULL);
+                QTC_ASSERT(file, return result);
                 stringRes = QFileInfo(file->name).fileName();
                 const QString alias = file->alias;
-                if(!alias.isEmpty())
+                if (!alias.isEmpty())
                     appendParenthesized(alias, stringRes);
             }
             result = stringRes;
@@ -638,7 +641,7 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const
     case Qt::DecorationRole:
         if (isFileNode) {
             // File node
-                Q_ASSERT(file != NULL);
+            QTC_ASSERT(file, return result);
             const QString path = m_resource_file.absolutePath(file->name);
             if (iconFileExtension(path)) {
                 const QIcon icon(path);
@@ -650,11 +653,11 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const
     case Qt::ToolTipRole:
         if (isFileNode) {
             // File node
-                Q_ASSERT(file != NULL);
+            QTC_ASSERT(file, return result);
             QString conv_file = m_resource_file.relativePath(file->name);
             QString stringRes = conv_file.replace(QDir::separator(), QLatin1Char('/'));
             const QString &alias_file = file->alias;
-            if(!alias_file.isEmpty())
+            if (!alias_file.isEmpty())
                     appendParenthesized(alias_file, stringRes);
 
             result = stringRes;
@@ -679,12 +682,12 @@ void ResourceModel::getItem(const QModelIndex &index, QString &prefix, QString &
     void * const internalPointer = index.internalPointer();
     Node * const node = reinterpret_cast<Node *>(internalPointer);
     Prefix * const p = node->prefix();
-    Q_ASSERT(p != NULL);
+    QTC_ASSERT(p, return);
     bool const isFileNode = (p != node);
 
     if (isFileNode) {
-        File * const f = node->file();
-        Q_ASSERT(f != NULL);
+        File *const f = node->file();
+        QTC_ASSERT(f, return);
         if (!f->alias.isEmpty())
             file = f->alias;
         else
@@ -696,7 +699,7 @@ void ResourceModel::getItem(const QModelIndex &index, QString &prefix, QString &
 
 QString ResourceModel::lang(const QModelIndex &index) const
 {
-    if(!index.isValid())
+    if (!index.isValid())
         return QString();
 
     return m_resource_file.lang(index.row());
@@ -704,14 +707,14 @@ QString ResourceModel::lang(const QModelIndex &index) const
 
 QString ResourceModel::alias(const QModelIndex &index) const
 {
-    if(!index.isValid() || !index.parent().isValid())
+    if (!index.isValid() || !index.parent().isValid())
         return QString();
     return m_resource_file.alias(index.parent().row(), index.row());
 }
 
 QString ResourceModel::file(const QModelIndex &index) const
 {
-    if(!index.isValid() || !index.parent().isValid())
+    if (!index.isValid() || !index.parent().isValid())
         return QString();
     return m_resource_file.file(index.parent().row(), index.row());
 }
@@ -852,7 +855,7 @@ void ResourceModel::changePrefix(const QModelIndex &model_idx, const QString &pr
     if (m_resource_file.prefix(prefix_idx) == ResourceFile::fixPrefix(prefix))
         return;
 
-    if(m_resource_file.contains(prefix))
+    if (m_resource_file.contains(prefix))
         return;
 
     m_resource_file.replacePrefix(prefix_idx, prefix);
@@ -880,7 +883,7 @@ void ResourceModel::changeAlias(const QModelIndex &index, const QString &alias)
     if (!index.parent().isValid())
         return;
 
-    if(m_resource_file.alias(index.parent().row(), index.row()) == alias)
+    if (m_resource_file.alias(index.parent().row(), index.row()) == alias)
         return;
     m_resource_file.replaceAlias(index.parent().row(), index.row(), alias);
     emit dataChanged(index, index);
diff --git a/shared/qrceditor/resourcefile_p.h b/shared/qrceditor/resourcefile_p.h
index 3276c2dec1e47881396c733a24e1d5929e473ab4..6643be39abaef21b8954a99d8905357f835dae1d 100644
--- a/shared/qrceditor/resourcefile_p.h
+++ b/shared/qrceditor/resourcefile_p.h
@@ -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;
diff --git a/shared/qrceditor/resourceview.cpp b/shared/qrceditor/resourceview.cpp
index 27a0a5a4254016277ba8a9f88316c7eadd9a07d1..d0d3a9d11c53076a0b8f9a804d59ba373effbefd 100644
--- a/shared/qrceditor/resourceview.cpp
+++ b/shared/qrceditor/resourceview.cpp
@@ -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);
@@ -476,7 +480,7 @@ bool ResourceView::load(QString fileName)
     const QFileInfo fi(fileName);
     m_qrcModel->setFileName(fi.absoluteFilePath());
 
-    if(!fi.exists())
+    if (!fi.exists())
         return false;
 
     const bool result = m_qrcModel->reload();
@@ -501,9 +505,8 @@ void ResourceView::changePrefix(const QModelIndex &index)
     QString const prefixAfter = QInputDialog::getText(this, tr("Change Prefix"), tr("Input Prefix:"),
         QLineEdit::Normal, prefixBefore, &ok);
 
-    if (ok) {
+    if (ok)
         addUndoCommand(preindex, PrefixProperty, prefixBefore, prefixAfter);
-    }
 }
 
 void ResourceView::changeLang(const QModelIndex &index)
@@ -522,7 +525,7 @@ void ResourceView::changeLang(const QModelIndex &index)
 
 void ResourceView::changeAlias(const QModelIndex &index)
 {
-    if(!index.parent().isValid())
+    if (!index.parent().isValid())
         return;
 
     bool ok = false;
@@ -531,9 +534,8 @@ void ResourceView::changeAlias(const QModelIndex &index)
     QString const aliasAfter = QInputDialog::getText(this, tr("Change File Alias"), tr("Alias:"),
         QLineEdit::Normal, aliasBefore, &ok);
 
-    if (ok) {
+    if (ok)
         addUndoCommand(index, AliasProperty, aliasBefore, aliasAfter);
-    }
 }
 
 QString ResourceView::currentAlias() const
@@ -570,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
     }
 }
 
@@ -581,19 +583,20 @@ 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, /**/);
     }
 }
 
-void ResourceView::advanceMergeId() {
+void ResourceView::advanceMergeId()
+{
     m_mergeId++;
-    if (m_mergeId < 0) {
+    if (m_mergeId < 0)
         m_mergeId = 0;
-    }
 }
 
 void ResourceView::addUndoCommand(const QModelIndex &nodeIndex, NodeProperty property,
-        const QString &before, const QString &after) {
+        const QString &before, const QString &after)
+{
     QUndoCommand * const command = new ModifyPropertyCommand(this, nodeIndex, property,
             m_mergeId, before, after);
     m_history->push(command);
diff --git a/shared/qrceditor/undocommands.cpp b/shared/qrceditor/undocommands.cpp
index 6b549326d584044219afeb8a7edbb1c6a2932050..246b69c0d71e2fe7978344c453dbfd4b1ac5ac6f 100644
--- a/shared/qrceditor/undocommands.cpp
+++ b/shared/qrceditor/undocommands.cpp
@@ -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,
diff --git a/shared/qtsingleapplication/qtlocalpeer.cpp b/shared/qtsingleapplication/qtlocalpeer.cpp
index f488e72134b29c8986064045457459cae22eb521..1e324106ad0b545e28349a49f9580670e1b4532f 100644
--- a/shared/qtsingleapplication/qtlocalpeer.cpp
+++ b/shared/qtsingleapplication/qtlocalpeer.cpp
@@ -50,9 +50,9 @@ static PProcessIdToSessionId pProcessIdToSessionId = 0;
 
 namespace SharedTools {
 
-const char* QtLocalPeer::ack = "ack";
+const char *QtLocalPeer::ack = "ack";
 
-QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
+QtLocalPeer::QtLocalPeer(QObject *parent, const QString &appId)
     : QObject(parent), id(appId)
 {
     if (id.isEmpty())
@@ -86,8 +86,6 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
     lockFile.open(QIODevice::ReadWrite);
 }
 
-
-
 bool QtLocalPeer::isClient()
 {
     if (lockFile.isLocked())
@@ -105,7 +103,6 @@ bool QtLocalPeer::isClient()
     return false;
 }
 
-
 bool QtLocalPeer::sendMessage(const QString &message, int timeout)
 {
     if (!isClient())
@@ -113,7 +110,7 @@ bool QtLocalPeer::sendMessage(const QString &message, int timeout)
 
     QLocalSocket socket;
     bool connOk = false;
-    for(int i = 0; i < 2; i++) {
+    for (int i = 0; i < 2; i++) {
         // Try twice, in case the other instance is just starting up
         socket.connectToServer(socketName);
         connOk = socket.waitForConnected(timeout/2);
@@ -139,7 +136,6 @@ bool QtLocalPeer::sendMessage(const QString &message, int timeout)
     return res;
 }
 
-
 void QtLocalPeer::receiveConnection()
 {
     QLocalSocket* socket = server->nextPendingConnection();
diff --git a/shared/scriptwrapper/wrap_helpers.h b/shared/scriptwrapper/wrap_helpers.h
index 21ed625c1619c2a7fe15787c033a93b02b7956a5..02db144a3e5e556ac09350add2a23170a73e43cf 100644
--- a/shared/scriptwrapper/wrap_helpers.h
+++ b/shared/scriptwrapper/wrap_helpers.h
@@ -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*)
diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp
index 45ad1f569a5f6d1f3a190fdb76d4ce19a78accfe..3e619548a2334a64790d5973612b06cca5c90dfe 100644
--- a/src/libs/cplusplus/CppDocument.cpp
+++ b/src/libs/cplusplus/CppDocument.cpp
@@ -32,6 +32,9 @@
 ***************************************************************************/
 
 #include "CppDocument.h"
+
+#include <utils/qtcassert.h>
+
 #include <Control.h>
 #include <TranslationUnit.h>
 #include <DiagnosticClient.h>
@@ -143,9 +146,9 @@ void Document::appendMacro(const Macro &macro)
     _definedMacros.append(macro);
 }
 
-void Document::addMacroUse(unsigned offset, unsigned length)
+void Document::addMacroUse(const Macro &macro, unsigned offset, unsigned length)
 {
-    _macroUses.append(Block(offset, offset + length));
+    _macroUses.append(MacroUse(macro, offset, offset + length));
 }
 
 TranslationUnit *Document::translationUnit() const
@@ -270,7 +273,7 @@ bool Document::parse(ParseMode mode)
 
 void Document::check()
 {
-    Q_ASSERT(! _globalNamespace);
+    QTC_ASSERT(!_globalNamespace, return);
 
     Semantic semantic(_control);
 
diff --git a/src/libs/cplusplus/CppDocument.h b/src/libs/cplusplus/CppDocument.h
index d289c579e9c6fddc2d4c0a0fbd31247c47a77e01..aaca36c18eee38455cb94d8ab09db826ad4145b0 100644
--- a/src/libs/cplusplus/CppDocument.h
+++ b/src/libs/cplusplus/CppDocument.h
@@ -68,8 +68,7 @@ public:
     void addIncludeFile(const QString &fileName);
 
     void appendMacro(const Macro &macro);
-
-    void addMacroUse(unsigned offset, unsigned length);
+    void addMacroUse(const Macro &macro, unsigned offset, unsigned length);
 
     Control *control() const;
     TranslationUnit *translationUnit() const;
@@ -177,12 +176,30 @@ public:
 
         inline unsigned end() const
         { return _end; }
+
+        bool contains(unsigned pos) const
+        { return pos >= _begin && pos < _end; }
+    };
+
+    class MacroUse: public Block {
+        Macro _macro;
+
+    public:
+        inline MacroUse(const Macro &macro,
+                        unsigned begin = 0,
+                        unsigned end = 0)
+            : Block(begin, end),
+              _macro(macro)
+        { }
+
+        const Macro &macro() const
+        { return _macro; }
     };
 
     QList<Block> skippedBlocks() const
     { return _skippedBlocks; }
 
-    QList<Block> macroUses() const
+    QList<MacroUse> macroUses() const
     { return _macroUses; }
 
 private:
@@ -197,7 +214,7 @@ private:
     QList<DiagnosticMessage> _diagnosticMessages;
     QList<Macro> _definedMacros;
     QList<Block> _skippedBlocks;
-    QList<Block> _macroUses;
+    QList<MacroUse> _macroUses;
 };
 
 } // end of namespace CPlusPlus
diff --git a/src/libs/cplusplus/OverviewModel.cpp b/src/libs/cplusplus/OverviewModel.cpp
index 20658778905013ba8f9b1c37989913b5921b3963..7f38cb8ba1a2fb8d06deaecfceddc2e23bd162ba 100644
--- a/src/libs/cplusplus/OverviewModel.cpp
+++ b/src/libs/cplusplus/OverviewModel.cpp
@@ -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();
                 }
diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp
index cfcd06cacd7067b55000916460c59aa08dcb5c83..6915e1169b0b532e06c797018c883b651fc771f7 100644
--- a/src/libs/cplusplus/ResolveExpression.cpp
+++ b/src/libs/cplusplus/ResolveExpression.cpp
@@ -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
diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp
index 7bdc9b95d69106790cc8650b7abe7c4c632a426b..83386e8079c5fca868024acb4be07b4e74a58cc1 100644
--- a/src/libs/cplusplus/pp-engine.cpp
+++ b/src/libs/cplusplus/pp-engine.cpp
@@ -164,7 +164,15 @@ protected:
     bool process_primary()
     {
         if ((*_lex)->is(T_INT_LITERAL)) {
-            _value.set_long(tokenSpell().toLong());
+            int base = 10;
+            const QByteArray spell = tokenSpell();
+            if (spell.at(0) == '0') {
+                if (spell.size() > 1 && (spell.at(1) == 'x' || spell.at(1) == 'X'))
+                    base = 16;
+                else
+                    base = 8;
+            }
+            _value.set_long(tokenSpell().toLong(0, base));
             ++(*_lex);
             return true;
         } else if (isTokenDefined()) {
@@ -367,7 +375,7 @@ protected:
     {
         process_xor();
 
-        while ((*_lex)->is(T_CARET)) {
+        while ((*_lex)->is(T_PIPE)) {
             const Token op = *(*_lex);
             ++(*_lex);
 
@@ -481,12 +489,12 @@ void pp::operator () (const QByteArray &filename,
                       const QByteArray &source,
                       QByteArray *result)
 {
-    const QByteArray previousFile = env.current_file;
-    env.current_file = filename;
+    const QByteArray previousFile = env.currentFile;
+    env.currentFile = filename;
 
     operator () (source, result);
 
-    env.current_file = previousFile;
+    env.currentFile = previousFile;
 }
 
 pp::State pp::createStateFromSource(const QByteArray &source) const
@@ -518,7 +526,7 @@ void pp::operator()(const QByteArray &source, QByteArray *result)
                 result->append(QByteArray::number(_dot->lineno));
                 result->append(' ');
                 result->append('"');
-                result->append(env.current_file);
+                result->append(env.currentFile);
                 result->append('"');
                 result->append('\n');
             } else {
@@ -604,28 +612,29 @@ void pp::operator()(const QByteArray &source, QByteArray *result)
                                    m->definition.constEnd(),
                                    result);
 
+                            m->hidden = false;
+
                             if (client)
                                 client->stopExpandingMacro(_dot->offset, *m);
 
-                            m->hidden = false;
                             continue;
                         } else {
                             QByteArray tmp;
-                            m->hidden = true;
 
                             if (client)
                                 client->startExpandingMacro(identifierToken->offset,
                                                             *m, spell);
+                            m->hidden = true;
 
                             expand(m->definition.constBegin(),
                                    m->definition.constEnd(),
                                    &tmp);
 
+                            m->hidden = false;
+
                             if (client)
                                 client->stopExpandingMacro(_dot->offset, *m);
 
-                            m->hidden = false;
-
                             m = 0; // reset the active the macro
 
                             pushState(createStateFromSource(tmp));
@@ -843,6 +852,8 @@ void pp::processDefine(TokenIterator firstToken, TokenIterator lastToken)
     }
 
     Macro macro;
+    macro.fileName = env.currentFile;
+    macro.line = env.currentLine;
     macro.name = tokenText(*tk);
     ++tk; // skip T_IDENTIFIER
 
diff --git a/src/libs/cplusplus/pp-environment.cpp b/src/libs/cplusplus/pp-environment.cpp
index a1ade3b189a6b7a6e639aa0716ae5330c0f46bc9..20491727a4ceb2cb9be060cc0d7e9a998ea92794 100644
--- a/src/libs/cplusplus/pp-environment.cpp
+++ b/src/libs/cplusplus/pp-environment.cpp
@@ -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,20 +81,22 @@ 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);
-    m->fileName = current_file;
-    m->line = currentLine;
 
     if (++_macro_count == _allocated_macros) {
         if (! _allocated_macros)
@@ -115,11 +120,13 @@ Macro *Environment::bind(const Macro &__macro)
     return m;
 }
 
-Macro *Environment::remove (const QByteArray &name)
+Macro *Environment::remove(const QByteArray &name)
 {
     Macro macro;
     macro.name = name;
     macro.hidden = true;
+    macro.fileName = currentFile;
+    macro.line = currentLine;
     return bind(macro);
 }
 
diff --git a/src/libs/cplusplus/pp-environment.h b/src/libs/cplusplus/pp-environment.h
index e2a75d29b819f4990b649ac428e8bd928e30c83f..4200b5ea0ff0548852535b699eb9680444599d5e 100644
--- a/src/libs/cplusplus/pp-environment.h
+++ b/src/libs/cplusplus/pp-environment.h
@@ -94,7 +94,7 @@ private:
     void rehash();
 
 public:
-    QByteArray current_file;
+    QByteArray currentFile;
     unsigned currentLine;
     bool hide_next;
 
diff --git a/src/libs/cplusplus/pp-macro-expander.cpp b/src/libs/cplusplus/pp-macro-expander.cpp
index 9ae9702fe18fa21dcd240b0f6c4d59ee21fbf5aa..e17dd873dba8e12370165e06285e3d157baa7350 100644
--- a/src/libs/cplusplus/pp-macro-expander.cpp
+++ b/src/libs/cplusplus/pp-macro-expander.cpp
@@ -73,7 +73,7 @@ const char *MacroExpander::operator () (const char *__first, const char *__last,
             __result->append(QByteArray::number(env.currentLine));
             __result->append(' ');
             __result->append('"');
-            __result->append(env.current_file);
+            __result->append(env.currentFile);
             __result->append('"');
             __result->append('\n');
             ++lines;
@@ -218,7 +218,7 @@ const char *MacroExpander::operator () (const char *__first, const char *__last,
                     else if (fast_name == "__FILE__")
                     {
                         __result->append('"');
-                        __result->append(env.current_file);
+                        __result->append(env.currentFile);
                         __result->append('"');
                         continue;
                     }
diff --git a/src/libs/cplusplus/pp-macro.h b/src/libs/cplusplus/pp-macro.h
index 494b7a4de7ff7df6a7567a88dd5367208848f921..887fff53b0a6128d13ebf439d872863e28207e11 100644
--- a/src/libs/cplusplus/pp-macro.h
+++ b/src/libs/cplusplus/pp-macro.h
@@ -57,6 +57,7 @@
 
 #include <QByteArray>
 #include <QVector>
+#include <QString>
 
 namespace CPlusPlus {
 
@@ -89,6 +90,33 @@ public:
             hashcode(0),
             state(0)
     { }
+
+    QString toString() const
+    {
+        QString text;
+        if (hidden)
+            text += QLatin1String("#undef ");
+        else
+            text += QLatin1String("#define ");
+        text += QString::fromUtf8(name.constData(), name.size());
+        if (function_like) {
+            text += QLatin1Char('(');
+            bool first = true;
+            foreach (const QByteArray formal, formals) {
+                if (! first)
+                    text += QLatin1String(", ");
+                else
+                    first = false;
+                text += QString::fromUtf8(formal.constData(), formal.size());
+            }
+            if (variadics)
+                text += QLatin1String("...");
+            text += QLatin1Char(')');
+        }
+        text += QLatin1Char(' ');
+        text += QString::fromUtf8(definition.constData(), definition.size());
+        return text;
+    }
 };
 
 } // namespace CPlusPlus
diff --git a/src/libs/extensionsystem/pluginmanager.cpp b/src/libs/extensionsystem/pluginmanager.cpp
index f6f623f66541d09ffc4ebf4371a7c0bda34995ce..3f7ba386e4e2d096d247cced281e457c26398d69 100644
--- a/src/libs/extensionsystem/pluginmanager.cpp
+++ b/src/libs/extensionsystem/pluginmanager.cpp
@@ -422,12 +422,12 @@ void PluginManager::formatPluginVersions(QTextStream &str) const
 void PluginManager::startTests()
 {
 #ifdef WITH_TESTS
-    foreach(PluginSpec *pluginSpec, d->testSpecs) {
+    foreach (PluginSpec *pluginSpec, d->testSpecs) {
         const QMetaObject *mo = pluginSpec->plugin()->metaObject();
         QStringList methods;
         methods.append("arg0");
         // We only want slots starting with "test"
-        for(int i = mo->methodOffset(); i < mo->methodCount(); ++i) {
+        for (int i = mo->methodOffset(); i < mo->methodCount(); ++i) {
             if (QByteArray(mo->method(i).signature()).startsWith("test")) {
                 QString method = QString::fromLatin1(mo->method(i).signature());
                 methods.append(method.left(method.size()-2));
diff --git a/src/libs/utils/classnamevalidatinglineedit.cpp b/src/libs/utils/classnamevalidatinglineedit.cpp
index 0210b96e702a20d627e20e83cfe30ced163d7247..aa6557574cfda5a69ee2efaecb1c9c2a994193b2 100644
--- a/src/libs/utils/classnamevalidatinglineedit.cpp
+++ b/src/libs/utils/classnamevalidatinglineedit.cpp
@@ -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(),
diff --git a/src/libs/utils/filenamevalidatinglineedit.cpp b/src/libs/utils/filenamevalidatinglineedit.cpp
index 5b308f5ce4728eef5823a2c82be842180438e5e3..a7e228903b56aeb4c99e704c49333b77b8ddaecd 100644
--- a/src/libs/utils/filenamevalidatinglineedit.cpp
+++ b/src/libs/utils/filenamevalidatinglineedit.cpp
@@ -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;
 }
 
diff --git a/src/libs/utils/filewizardpage.cpp b/src/libs/utils/filewizardpage.cpp
index 3e85b34d44b729142ff233b5f16f2d37cdc06e23..da892faf03b9f7c67d261d1c4c844edd488eba5c 100644
--- a/src/libs/utils/filewizardpage.cpp
+++ b/src/libs/utils/filewizardpage.cpp
@@ -92,7 +92,7 @@ void FileWizardPage::setName(const QString &name)
 
 void FileWizardPage::changeEvent(QEvent *e)
 {
-    switch(e->type()) {
+    switch (e->type()) {
     case QEvent::LanguageChange:
         m_d->m_ui.retranslateUi(this);
         break;
diff --git a/src/libs/utils/pathchooser.cpp b/src/libs/utils/pathchooser.cpp
index 68ebe9cbbfd429bd1578d4641ac52151e0f8d2d1..81a2228e669f96911aeaa84cc07f5d4284d7ec82 100644
--- a/src/libs/utils/pathchooser.cpp
+++ b/src/libs/utils/pathchooser.cpp
@@ -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 {
@@ -55,7 +57,8 @@ namespace Utils {
 #endif
 
 // ------------------ PathValidatingLineEdit
-class PathValidatingLineEdit : public BaseValidatingLineEdit {
+class PathValidatingLineEdit : public BaseValidatingLineEdit
+{
 public:
     explicit PathValidatingLineEdit(PathChooser *chooser, QWidget *parent = 0);
 
@@ -70,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
@@ -79,7 +82,8 @@ bool PathValidatingLineEdit::validate(const QString &value, QString *errorMessag
 }
 
 // ------------------ PathChooserPrivate
-struct PathChooserPrivate {
+struct PathChooserPrivate
+{
     PathChooserPrivate(PathChooser *chooser);
 
     PathValidatingLineEdit *m_lineEdit;
@@ -160,9 +164,9 @@ void PathChooser::slotBrowse()
 
     // TODO make cross-platform
     // Delete trailing slashes unless it is "/", only
-    if (!newPath .isEmpty()) {
-        if (newPath .size() > 1 && newPath .endsWith(QDir::separator()))
-            newPath .truncate(newPath .size() - 1);
+    if (!newPath.isEmpty()) {
+        if (newPath.size() > 1 && newPath.endsWith(QDir::separator()))
+            newPath.truncate(newPath.size() - 1);
         setPath(newPath);
     }
 }
@@ -174,7 +178,7 @@ bool PathChooser::isValid() const
 
 QString PathChooser::errorMessage() const
 {
-    return  m_d->m_lineEdit->errorMessage();
+    return m_d->m_lineEdit->errorMessage();
 }
 
 bool PathChooser::validatePath(const QString &path, QString *errorMessage)
@@ -207,17 +211,19 @@ bool PathChooser::validatePath(const QString &path, QString *errorMessage)
     // Check expected kind
     switch (m_d->m_acceptingKind) {
     case PathChooser::Directory:
-        if (!isDir)
+        if (!isDir) {
             if (errorMessage)
                 *errorMessage = tr("The path '%1' is not a directory.").arg(path);
             return false;
+        }
         break;
 
     case PathChooser::File:
-        if (isDir)
+        if (isDir) {
             if (errorMessage)
                 *errorMessage = tr("The path '%1' is not a file.").arg(path);
             return false;
+        }
         break;
 
     case PathChooser::Command:
diff --git a/src/libs/utils/projectintropage.cpp b/src/libs/utils/projectintropage.cpp
index 8d3705719377fea03909804ada1576633d92072e..63123138730a7037c148faf8cbc005af95991e74 100644
--- a/src/libs/utils/projectintropage.cpp
+++ b/src/libs/utils/projectintropage.cpp
@@ -117,7 +117,7 @@ void ProjectIntroPage::setDescription(const QString &description)
 
 void ProjectIntroPage::changeEvent(QEvent *e)
 {
-    switch(e->type()) {
+    switch (e->type()) {
     case QEvent::LanguageChange:
         m_d->m_ui.retranslateUi(this);
         break;
diff --git a/src/plugins/debugger/assert.h b/src/libs/utils/qtcassert.h
similarity index 84%
rename from src/plugins/debugger/assert.h
rename to src/libs/utils/qtcassert.h
index 014bb3b25d382bf787490e9e99c8578cb09fa203..f75d225f6e65ae19db688e04b833b69e18842f21 100644
--- a/src/plugins/debugger/assert.h
+++ b/src/libs/utils/qtcassert.h
@@ -31,16 +31,16 @@
 **
 ***************************************************************************/
 
-#ifndef DEBUGGER_QWB_ASSERT_H
-#define DEBUGGER_QWB_ASSERT_H
+#ifndef QTC_ASSERT_H
+#define QTC_ASSERT_H
 
-#ifdef Q_OS_UNIX
-#define QWB_ASSERT(cond, action) \
+#include <QtCore/QDebug>
+
+// we do not use the  'do {...} while (0)' idiom here to be able to use
+// 'break' and 'continue' as 'actions'.
+
+#define QTC_ASSERT(cond, action) \
     if(cond){}else{qDebug()<<"ASSERTION"<<#cond<<"FAILED"<<__FILE__<<__LINE__;action;}
-#else
-#define QWB_ASSERT(cond, action) \
-    if(cond){}else{qDebug()<<"ASSERTION"<<#cond<<"FAILED";action;}
-#endif
 
-#endif // DEBUGGER_QWB_ASSERT_H
+#endif // QTC_ASSERT_H
 
diff --git a/src/libs/utils/submiteditorwidget.cpp b/src/libs/utils/submiteditorwidget.cpp
index 85c1124149082549da7c6ead507847464920aa69..4aa021e63ecfb4eb00e6bb08c65263b54adecbc0 100644
--- a/src/libs/utils/submiteditorwidget.cpp
+++ b/src/libs/utils/submiteditorwidget.cpp
@@ -46,7 +46,8 @@ namespace Utils {
 
 // QActionPushButton: A push button tied to an action
 // (similar to a QToolButton)
-class QActionPushButton : public QPushButton {
+class QActionPushButton : public QPushButton
+{
     Q_OBJECT
 public:
     explicit QActionPushButton(QAction *a);
@@ -319,7 +320,7 @@ void SubmitEditorWidget::fileSelectionChanged()
 
 void SubmitEditorWidget::changeEvent(QEvent *e)
 {
-    switch(e->type()) {
+    switch (e->type()) {
     case QEvent::LanguageChange:
         m_d->m_ui.retranslateUi(this);
         break;
diff --git a/src/plugins/bineditor/bineditor.cpp b/src/plugins/bineditor/bineditor.cpp
index 05e24a77b49b6b7c8e1b5028480bf3c2ef18f8b9..9ca1dbfb74985930719ffabbe8e41664abecfbdf 100644
--- a/src/plugins/bineditor/bineditor.cpp
+++ b/src/plugins/bineditor/bineditor.cpp
@@ -222,7 +222,7 @@ void BinEditor::scrollContentsBy(int dx, int dy)
 void BinEditor::changeEvent(QEvent *e)
 {
     QAbstractScrollArea::changeEvent(e);
-    if(e->type() == QEvent::ActivationChange) {
+    if (e->type() == QEvent::ActivationChange) {
         if (!isActiveWindow())
             m_autoScrollTimer.stop();
     }
@@ -450,7 +450,7 @@ void BinEditor::paintEvent(QPaintEvent *e)
         for (int c = 0; c < 16; ++c) {
             int pos = line * 16 + c;
             if (pos >= m_data.size()) {
-                while(c < 16) {
+                while (c < 16) {
                     itemStringData[c*3] = itemStringData[c*3+1] = ' ';
                     ++c;
                 }
diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp
index fd4541a01dd2b13f6d1e94f15bd1a0a25d012c53..a9377730fd820f7b7cb30ddf7513d9d34939d4b4 100644
--- a/src/plugins/bookmarks/bookmarkmanager.cpp
+++ b/src/plugins/bookmarks/bookmarkmanager.cpp
@@ -32,6 +32,7 @@
 ***************************************************************************/
 
 #include "bookmarkmanager.h"
+
 #include "bookmark.h"
 #include "bookmarksplugin.h"
 #include "bookmarks_global.h"
@@ -41,12 +42,14 @@
 #include <coreplugin/editormanager/editormanager.h>
 #include <coreplugin/uniqueidmanager.h>
 #include <texteditor/basetexteditor.h>
+#include <utils/qtcassert.h>
 
-#include <QtGui/QAction>
-#include <QtCore/QFileInfo>
 #include <QtCore/QDebug>
-#include <QtGui/QPainter>
+#include <QtCore/QFileInfo>
+
+#include <QtGui/QAction>
 #include <QtGui/QContextMenuEvent>
+#include <QtGui/QPainter>
 
 Q_DECLARE_METATYPE(Bookmarks::Internal::Bookmark*)
 
@@ -173,7 +176,7 @@ void BookmarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
 //        int idx;
 //        forever {
 //            idx = directory.lastIndexOf("/", pos-1);
-//            if(idx == -1) {
+//            if (idx == -1) {
 //                // Can't happen, this means the string did fit after all?
 //                break;
 //            }
@@ -272,7 +275,7 @@ void BookmarkView::removeAll()
 void BookmarkView::setModel(QAbstractItemModel *model)
 {
     BookmarkManager *manager = qobject_cast<BookmarkManager *>(model);
-    Q_ASSERT(manager);
+    QTC_ASSERT(manager, return);
     QListView::setModel(model);
     setSelectionModel(manager->selectionModel());
     setSelectionMode(QAbstractItemView::SingleSelection);
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index 5569c900f2b49dbbe8c269f49a888c4d3f6e4f12..423fa2dcb3f172009cfa869110a869e6c93451a8 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -32,15 +32,20 @@
 ***************************************************************************/
 
 #include "cmakeproject.h"
+
 #include "cmakeprojectconstants.h"
 #include "cmakeprojectnodes.h"
+#include "cmakerunconfiguration.h"
 #include "cmakestep.h"
 #include "makestep.h"
 
 #include <extensionsystem/pluginmanager.h>
 #include <cpptools/cppmodelmanagerinterface.h>
+#include <utils/qtcassert.h>
 
 #include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QProcess>
 
 using namespace CMakeProjectManager;
 using namespace CMakeProjectManager::Internal;
@@ -48,20 +53,31 @@ using namespace CMakeProjectManager::Internal;
 CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
     : m_manager(manager), m_fileName(fileName), m_rootNode(new CMakeProjectNode(m_fileName))
 {
-    //TODO
+
     m_file = new CMakeFile(this, fileName);
     QDir dir = QFileInfo(m_fileName).absoluteDir();
     QString cbpFile = findCbpFile(dir);
     if (cbpFile.isEmpty())
         cbpFile = createCbpFile(dir);
 
+    //TODO move this parsing to a seperate method, which is also called if the CMakeList.txt is updated
     CMakeCbpParser cbpparser;
     if (cbpparser.parseCbpFile(cbpFile)) {
+        // TODO do a intelligent updating of the tree
         buildTree(m_rootNode, cbpparser.fileList());
-        foreach(ProjectExplorer::FileNode *fn, cbpparser.fileList())
+        foreach (ProjectExplorer::FileNode *fn, cbpparser.fileList())
             m_files.append(fn->path());
         m_files.sort();
 
+        m_targets = cbpparser.targets();
+        qDebug()<<"Printing targets";
+        foreach(CMakeTarget ct, m_targets) {
+            qDebug()<<ct.title<<" with executable:"<<ct.executable;
+            qDebug()<<"WD:"<<ct.workingDirectory;
+            qDebug()<<ct.makeCommand<<ct.makeCleanCommand;
+            qDebug()<<"";
+        }
+
         CppTools::CppModelManagerInterface *modelmanager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
         if (modelmanager) {
             CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
@@ -69,6 +85,7 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
             // TODO we only want C++ files, not all other stuff that might be in the project
             pinfo.sourceFiles = m_files;
             // TODO defines
+            // TODO gcc preprocessor files
             modelmanager->updateProjectInfo(pinfo);
         }
     } else {
@@ -87,25 +104,27 @@ QString CMakeProject::findCbpFile(const QDir &directory)
     //   TODO the cbp file is named like the project() command in the CMakeList.txt file
     //   so this method below could find the wrong cbp file, if the user changes the project()
     //   name
-    foreach(const QString &cbpFile , directory.entryList())
-    {
-        if (cbpFile.endsWith(".cbp")) {
+    foreach (const QString &cbpFile , directory.entryList()) {
+        if (cbpFile.endsWith(".cbp"))
             return directory.path() + "/" + cbpFile;
-        }
     }
     return QString::null;
 }
 
-
-QString CMakeProject::createCbpFile(const QDir &)
+QString CMakeProject::createCbpFile(const QDir &directory)
 {
-    // TODO create a cbp file.
-    //  Issue: Where to create it? We want to do that in the build directory
-    //         but at this stage we don't know the build directory yet
-    //         So create it in a temp directory?
-    //  Issue: We want to reuse whatever CMakeCache.txt that is alread there, which
-    //         would indicate, creating it in the build directory
-    //         Or we could use a temp directory and use -C builddirectory
+    // We create a cbp file, only if we didn't find a cbp file in the base directory
+    // Yet that can still override cbp files in subdirectories
+    // And we are creating tons of files in the source directories
+    // All of that is not really nice.
+    // The mid term plan is to move away from the CodeBlocks Generator and use our own
+    // QtCreator generator, which actually can be very similar to the CodeBlock Generator
+
+    // TODO we need to pass on the same paremeters as the cmakestep
+    QProcess cmake;
+    cmake.setWorkingDirectory(directory.absolutePath());
+    cmake.start("cmake", QStringList() << "-GCodeBlocks - Unix Makefiles");
+
     return QString::null;
 }
 
@@ -113,7 +132,7 @@ void CMakeProject::buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::
 {
     //m_rootNode->addFileNodes(fileList, m_rootNode);
     qSort(list.begin(), list.end(), ProjectExplorer::ProjectNode::sortNodesByPath);
-    foreach( ProjectExplorer::FileNode *fn, list) {
+    foreach (ProjectExplorer::FileNode *fn, list) {
         // Get relative path to rootNode
         QString parentDir = QFileInfo(fn->path()).absolutePath();
         ProjectExplorer::FolderNode *folder = findOrCreateFolder(rootNode, parentDir);
@@ -127,10 +146,10 @@ ProjectExplorer::FolderNode *CMakeProject::findOrCreateFolder(CMakeProjectNode *
     QString relativePath = QDir(QFileInfo(rootNode->path()).path()).relativeFilePath(directory);
     QStringList parts = relativePath.split("/");
     ProjectExplorer::FolderNode *parent = rootNode;
-    foreach(const QString &part, parts) {
+    foreach (const QString &part, parts) {
         // Find folder in subFolders
         bool found = false;
-        foreach(ProjectExplorer::FolderNode *folder, parent->subFolderNodes()) {
+        foreach (ProjectExplorer::FolderNode *folder, parent->subFolderNodes()) {
             if (QFileInfo(folder->path()).fileName() == part) {
                 // yeah found something :)
                 parent = folder;
@@ -227,27 +246,35 @@ QStringList CMakeProject::files(FilesMode fileMode) const
 void CMakeProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer)
 {
     // TODO
-    Q_UNUSED(writer);
+    Project::saveSettingsImpl(writer);
 }
 
 void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader)
 {
     // TODO
-    Q_UNUSED(reader);
+    Project::restoreSettingsImpl(reader);
     if (buildConfigurations().isEmpty()) {
         // No build configuration, adding those
-
-        // TODO do we want to create one build configuration per target?
-        // or how do we want to handle that?
-
         CMakeStep *cmakeStep = new CMakeStep(this);
         MakeStep *makeStep = new MakeStep(this);
 
         insertBuildStep(0, cmakeStep);
         insertBuildStep(1, makeStep);
 
-        addBuildConfiguration("all");
+        // Create build configurations of m_targets
+        qDebug()<<"Create build configurations of m_targets";
+        foreach(const CMakeTarget &ct, m_targets) {
+            addBuildConfiguration(ct.title);
+            makeStep->setValue(ct.title, "makeCommand", ct.makeCommand);
+            makeStep->setValue(ct.title, "makeCleanCommand", ct.makeCleanCommand);
+
+            QSharedPointer<ProjectExplorer::RunConfiguration> rc(new CMakeRunConfiguration(this, ct.executable, ct.workingDirectory));
+            // TODO set build configuration to build before it can be run
+            addRunConfiguration(rc);
+            setActiveRunConfiguration(rc); // TODO what exactly shall be the active run configuration?
+        }
         setActiveBuildConfiguration("all");
+
     }
     // Restoring is fine
 }
@@ -332,7 +359,7 @@ bool CMakeCbpParser::parseCbpFile(const QString &fileName)
     if (fi.exists() && fi.open(QFile::ReadOnly)) {
         setDevice(&fi);
 
-        while(!atEnd()) {
+        while (!atEnd()) {
             readNext();
             if (name() == "CodeBlocks_project_file") {
                 parseCodeBlocks_project_file();
@@ -350,7 +377,7 @@ bool CMakeCbpParser::parseCbpFile(const QString &fileName)
 
 void CMakeCbpParser::parseCodeBlocks_project_file()
 {
-    while(!atEnd()) {
+    while (!atEnd()) {
         readNext();
         if (isEndElement()) {
             return;
@@ -364,7 +391,7 @@ void CMakeCbpParser::parseCodeBlocks_project_file()
 
 void CMakeCbpParser::parseProject()
 {
-    while(!atEnd()) {
+    while (!atEnd()) {
         readNext();
         if (isEndElement()) {
             return;
@@ -380,7 +407,7 @@ void CMakeCbpParser::parseProject()
 
 void CMakeCbpParser::parseBuild()
 {
-    while(!atEnd()) {
+    while (!atEnd()) {
         readNext();
         if (isEndElement()) {
             return;
@@ -394,14 +421,16 @@ void CMakeCbpParser::parseBuild()
 
 void CMakeCbpParser::parseTarget()
 {
-    m_targetOutput.clear();
     m_targetType = false;
-    while(!atEnd()) {
+    m_target.clear();
+
+    if (attributes().hasAttribute("title"))
+        m_target.title = attributes().value("title").toString();
+    while (!atEnd()) {
         readNext();
         if (isEndElement()) {
-            if (m_targetType && !m_targetOutput.isEmpty()) {
-                qDebug()<<"found target "<<m_targetOutput;
-                m_targets.insert(m_targetOutput);
+            if (m_targetType || m_target.title == "all") {
+                m_targets.append(m_target);
             }
             return;
         } else if (name() == "Compiler") {
@@ -417,10 +446,58 @@ void CMakeCbpParser::parseTarget()
 void CMakeCbpParser::parseTargetOption()
 {
     if (attributes().hasAttribute("output"))
-        m_targetOutput = attributes().value("output").toString();
+        m_target.executable = attributes().value("output").toString();
     else if (attributes().hasAttribute("type") && attributes().value("type") == "1")
         m_targetType = true;
-    while(!atEnd()) {
+    else if (attributes().hasAttribute("working_dir"))
+        m_target.workingDirectory = attributes().value("working_dir").toString();
+    while (!atEnd()) {
+        readNext();
+        if (isEndElement()) {
+            return;
+        } else if (name() == "MakeCommand") {
+            parseMakeCommand();
+        } else if (isStartElement()) {
+            parseUnknownElement();
+        }
+    }
+}
+
+void CMakeCbpParser::parseMakeCommand()
+{
+    while (!atEnd()) {
+        readNext();
+        if (isEndElement()) {
+            return;
+        } else if (name() == "Build") {
+            parseTargetBuild();
+        } else if (name() == "Clean") {
+            parseTargetClean();
+        } else if (isStartElement()) {
+            parseUnknownElement();
+        }
+    }
+}
+
+void CMakeCbpParser::parseTargetBuild()
+{
+    if (attributes().hasAttribute("command"))
+        m_target.makeCommand = attributes().value("command").toString();
+    while (!atEnd()) {
+        readNext();
+        if (isEndElement()) {
+            return;
+        } else if (isStartElement()) {
+            parseUnknownElement();
+        }
+    }
+}
+
+void CMakeCbpParser::parseTargetClean()
+{
+    if (attributes().hasAttribute("command"))
+        m_target.makeCleanCommand = attributes().value("command").toString();
+    while (!atEnd()) {
         readNext();
         if (isEndElement()) {
             return;
@@ -432,7 +509,7 @@ void CMakeCbpParser::parseTargetOption()
 
 void CMakeCbpParser::parseCompiler()
 {
-    while(!atEnd()) {
+    while (!atEnd()) {
         readNext();
         if (isEndElement()) {
             return;
@@ -447,7 +524,7 @@ void CMakeCbpParser::parseCompiler()
 void CMakeCbpParser::parseAdd()
 {
     m_includeFiles.append(attributes().value("directory").toString());
-    while(!atEnd()) {
+    while (!atEnd()) {
         readNext();
         if (isEndElement()) {
             return;
@@ -463,7 +540,7 @@ void CMakeCbpParser::parseUnit()
     QString fileName = attributes().value("filename").toString();
     if (!fileName.endsWith(".rule"))
         m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::SourceType, false));
-    while(!atEnd()) {
+    while (!atEnd()) {
         readNext();
         if (isEndElement()) {
             return;
@@ -475,7 +552,7 @@ void CMakeCbpParser::parseUnit()
 
 void CMakeCbpParser::parseUnknownElement()
 {
-    Q_ASSERT(isStartElement());
+    QTC_ASSERT(isStartElement(), /**/);
 
     while (!atEnd()) {
         readNext();
@@ -497,3 +574,18 @@ QStringList CMakeCbpParser::includeFiles()
 {
     return m_includeFiles;
 }
+
+QList<CMakeTarget> CMakeCbpParser::targets()
+{
+    return m_targets;
+}
+
+void CMakeTarget::clear()
+{
+    executable = QString::null;
+    makeCommand = QString::null;
+    makeCleanCommand = QString::null;
+    workingDirectory = QString::null;
+    title = QString::null;
+}
+
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h
index a0c821ada5ebbe5e61267fa3f41824fdbac9d119..2a0314fda1a2676c74d5190dc69ca8b50c728c2c 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.h
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.h
@@ -49,6 +49,16 @@ namespace Internal{
 
 class CMakeFile;
 
+struct CMakeTarget
+{
+    QString title;
+    QString executable;
+    QString workingDirectory;
+    QString makeCommand;
+    QString makeCleanCommand;
+    void clear();
+};
+
 class CMakeProject : public ProjectExplorer::Project
 {
     Q_OBJECT
@@ -105,6 +115,7 @@ private:
     // TODO probably need a CMake specific node structure
     CMakeProjectNode* m_rootNode;
     QStringList m_files;
+    QList<CMakeTarget> m_targets;
 
 protected:
     virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
@@ -118,23 +129,27 @@ public:
     bool parseCbpFile(const QString &fileName);
     QList<ProjectExplorer::FileNode *> fileList();
     QStringList includeFiles();
+    QList<CMakeTarget> targets();
 private:
     void parseCodeBlocks_project_file();
     void parseProject();
     void parseBuild();
     void parseTarget();
     void parseTargetOption();
+    void parseMakeCommand();
+    void parseTargetBuild();
+    void parseTargetClean();
     void parseCompiler();
     void parseAdd();
     void parseUnit();
     void parseUnknownElement();
 
-    QSet<QString> m_targets;
     QList<ProjectExplorer::FileNode *> m_fileList;
     QStringList m_includeFiles;
 
-    QString m_targetOutput;
+    CMakeTarget m_target;
     bool m_targetType;
+    QList<CMakeTarget> m_targets;
 };
 
 class CMakeFile : public Core::IFile
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h b/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h
index 4832f17f26383d9deab8e48d2f9820068e95fa0e..713005899155864cacd987ade0c869d71ca17296 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h
@@ -41,6 +41,7 @@ const char * const PROJECTCONTEXT = "CMakeProject.ProjectContext";
 const char * const CMAKEMIMETYPE  = "text/x-cmake"; // TOOD check that this is correct
 const char * const CMAKESTEP      = "CMakeProjectManager.CMakeStep";
 const char * const MAKESTEP       = "CMakeProjectManager.MakeStep";
+const char * const CMAKERUNCONFIGURATION = "CMakeProjectManager.CMakeRunConfiguration";
 
 
 } // namespace Constants
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
index afca26b265b2d355d643d0c9c3f4ad7d385372da..74f69fea4abb6116609bb704cc399e52259369b2 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
@@ -8,11 +8,13 @@ HEADERS = cmakeproject.h \
     cmakeprojectconstants.h \
     cmakeprojectnodes.h \
     cmakestep.h \
-    makestep.h
+    makestep.h \
+    cmakerunconfiguration.h
 SOURCES = cmakeproject.cpp \
     cmakeprojectplugin.cpp \
     cmakeprojectmanager.cpp \
     cmakeprojectnodes.cpp \
     cmakestep.cpp \
-    makestep.cpp
+    makestep.cpp \
+    cmakerunconfiguration.cpp
 RESOURCES += cmakeproject.qrc
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
index 2b59a47c8e277669a9c11afab67776a6457e328e..932278a32c0c381567bb804ddc7e973b858e7e9a 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
@@ -33,6 +33,7 @@
 
 #include "cmakeprojectplugin.h"
 #include "cmakeprojectmanager.h"
+#include "cmakerunconfiguration.h"
 
 #include <coreplugin/icore.h>
 #include <coreplugin/mimedatabase.h>
@@ -57,6 +58,7 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
     if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":cmakeproject/CMakeProject.mimetypes.xml"), errorMessage))
         return false;
     addAutoReleasedObject(new CMakeManager());
+    addAutoReleasedObject(new CMakeRunConfigurationFactory());
     return true;
 }
 
diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d8bc8e795babf71a514a2233207df10126ecc12b
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp
@@ -0,0 +1,157 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact:  Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file.  Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception
+** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+
+#include "cmakerunconfiguration.h"
+
+#include "cmakeproject.h"
+#include "cmakeprojectconstants.h"
+
+#include <projectexplorer/environment.h>
+#include <utils/qtcassert.h>
+
+using namespace CMakeProjectManager;
+using namespace CMakeProjectManager::Internal;
+
+CMakeRunConfiguration::CMakeRunConfiguration(CMakeProject *pro, const QString &target, const QString &workingDirectory)
+    : ProjectExplorer::ApplicationRunConfiguration(pro), m_target(target), m_workingDirectory(workingDirectory)
+{
+    setName(target);
+}
+
+CMakeRunConfiguration::~CMakeRunConfiguration()
+{
+}
+
+QString CMakeRunConfiguration::type() const
+{
+    return Constants::CMAKERUNCONFIGURATION;
+}
+
+QString CMakeRunConfiguration::executable() const
+{
+    return m_target;
+}
+
+ProjectExplorer::ApplicationRunConfiguration::RunMode CMakeRunConfiguration::runMode() const
+{
+    return ProjectExplorer::ApplicationRunConfiguration::Gui;
+}
+
+QString CMakeRunConfiguration::workingDirectory() const
+{
+    return m_workingDirectory;
+}
+
+QStringList CMakeRunConfiguration::commandLineArguments() const
+{
+    // TODO
+    return QStringList();
+}
+
+ProjectExplorer::Environment CMakeRunConfiguration::environment() const
+{
+    // TODO
+    return ProjectExplorer::Environment::systemEnvironment();
+}
+
+void CMakeRunConfiguration::save(ProjectExplorer::PersistentSettingsWriter &writer) const
+{
+    ProjectExplorer::ApplicationRunConfiguration::save(writer);
+}
+
+void CMakeRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReader &reader)
+{
+    ProjectExplorer::ApplicationRunConfiguration::restore(reader);
+}
+
+QWidget *CMakeRunConfiguration::configurationWidget()
+{
+    //TODO
+    return new QWidget();
+}
+
+// Factory
+CMakeRunConfigurationFactory::CMakeRunConfigurationFactory()
+{
+
+}
+
+CMakeRunConfigurationFactory::~CMakeRunConfigurationFactory()
+{
+
+}
+
+// used to recreate the runConfigurations when restoring settings
+bool CMakeRunConfigurationFactory::canCreate(const QString &type) const
+{
+    if (type.startsWith(Constants::CMAKERUNCONFIGURATION))
+        return true;
+    return false;
+}
+
+// used to show the list of possible additons to a project, returns a list of types
+QStringList CMakeRunConfigurationFactory::canCreate(ProjectExplorer::Project *project) const
+{
+    CMakeProject *pro = qobject_cast<CMakeProject *>(project);
+    if (!pro)
+        return QStringList();
+    // TODO gather all targets and return them here
+    return QStringList();
+}
+
+// used to translate the types to names to display to the user
+QString CMakeRunConfigurationFactory::nameForType(const QString &type) const
+{
+    QTC_ASSERT(type.startsWith(Constants::CMAKERUNCONFIGURATION), /**/);
+
+    if (type == Constants::CMAKERUNCONFIGURATION)
+        return "CMake"; // Doesn't happen
+    else
+        return type.mid(QString(Constants::CMAKERUNCONFIGURATION).length());
+}
+
+QSharedPointer<ProjectExplorer::RunConfiguration> CMakeRunConfigurationFactory::create(ProjectExplorer::Project *project, const QString &type)
+{
+    CMakeProject *pro = qobject_cast<CMakeProject *>(project);
+    QTC_ASSERT(pro, /**/);
+    if (type == Constants::CMAKERUNCONFIGURATION) {
+        // Restoring, filename will be added by restoreSettings
+        QSharedPointer<ProjectExplorer::RunConfiguration> rc(new CMakeRunConfiguration(pro, QString::null, QString::null));
+        return rc;
+    } else {
+        // Adding new
+        QString file = type.mid(QString(Constants::CMAKERUNCONFIGURATION).length());
+        QSharedPointer<ProjectExplorer::RunConfiguration> rc(new CMakeRunConfiguration(pro, file, QString::null));
+        return rc;
+    }
+}
diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h
new file mode 100644
index 0000000000000000000000000000000000000000..082364e3042ad5a7594034f0c41715533b2932b0
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h
@@ -0,0 +1,93 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact:  Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file.  Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception
+** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+
+#ifndef CMAKERUNCONFIGURATION_H
+#define CMAKERUNCONFIGURATION_H
+
+#include <projectexplorer/applicationrunconfiguration.h>
+#include <projectexplorer/environment.h>
+#include <projectexplorer/persistentsettings.h>
+
+namespace CMakeProjectManager {
+namespace Internal {
+
+class CMakeProject;
+
+class CMakeRunConfiguration : public ProjectExplorer::ApplicationRunConfiguration
+{
+public:
+    CMakeRunConfiguration(CMakeProject *pro, const QString &target, const QString &workingDirectory);
+    virtual ~CMakeRunConfiguration();
+    virtual QString type() const;
+    virtual QString executable() const;
+    virtual RunMode runMode() const;
+    virtual QString workingDirectory() const;
+    virtual QStringList commandLineArguments() const;
+    virtual ProjectExplorer::Environment environment() const;
+    virtual QWidget *configurationWidget();
+
+    virtual void save(ProjectExplorer::PersistentSettingsWriter &writer) const;
+    virtual void restore(const ProjectExplorer::PersistentSettingsReader &reader);
+private:
+    QString m_target;
+    QString m_workingDirectory;
+};
+
+/* The run configuration factory is used for restoring run configurations from
+ * settings. And used to create new runconfigurations in the "Run Settings" Dialog.
+ * For the first case bool canCreate(const QString &type) and
+ * QSharedPointer<RunConfiguration> create(Project *project, QString type) are used.
+ * For the second type the functions QStringList canCreate(Project *pro) and
+ * QString nameForType(const QString&) are used to generate a list of creatable
+ * RunConfigurations, and create(..) is used to create it.
+ */
+class CMakeRunConfigurationFactory : public QObject
+{
+    Q_OBJECT;
+public:
+    CMakeRunConfigurationFactory();
+    virtual ~CMakeRunConfigurationFactory();
+    // used to recreate the runConfigurations when restoring settings
+    virtual bool canCreate(const QString &type) const;
+    // used to show the list of possible additons to a project, returns a list of types
+    virtual QStringList canCreate(ProjectExplorer::Project *pro) const;
+    // used to translate the types to names to display to the user
+    virtual QString nameForType(const QString &type) const;
+    virtual QSharedPointer<ProjectExplorer::RunConfiguration> create(ProjectExplorer::Project *project, const QString &type);
+};
+
+
+}
+}
+
+#endif // CMAKERUNCONFIGURATION_H
diff --git a/src/plugins/cmakeprojectmanager/cmakestep.cpp b/src/plugins/cmakeprojectmanager/cmakestep.cpp
index 0c267ca2c4cea394333b0a6bf4b1bb6d59fbbf47..045fa46a241532a425ad38d41cc51fee62027f7a 100644
--- a/src/plugins/cmakeprojectmanager/cmakestep.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakestep.cpp
@@ -32,8 +32,11 @@
 ***************************************************************************/
 
 #include "cmakestep.h"
-#include "cmakeprojectconstants.h"
+
 #include "cmakeproject.h"
+#include "cmakeprojectconstants.h"
+
+#include <utils/qtcassert.h>
 
 using namespace CMakeProjectManager;
 using namespace CMakeProjectManager::Internal;
@@ -41,12 +44,10 @@ using namespace CMakeProjectManager::Internal;
 CMakeStep::CMakeStep(CMakeProject *pro)
     : AbstractProcessStep(pro), m_pro(pro)
 {
-
 }
 
 CMakeStep::~CMakeStep()
 {
-
 }
 
 bool CMakeStep::init(const QString &buildConfiguration)
@@ -61,6 +62,11 @@ bool CMakeStep::init(const QString &buildConfiguration)
 
 void CMakeStep::run(QFutureInterface<bool> &fi)
 {
+    // TODO we want to only run cmake if the command line arguments or
+    // the CmakeLists.txt has actually changed
+    // And we want all of them to share the SAME command line arguments
+    // Shadow building ruins this, hmm, hmm
+    //
     AbstractProcessStep::run(fi);
 }
 
@@ -109,9 +115,9 @@ bool CMakeBuildStepFactory::canCreate(const QString &name) const
 
 ProjectExplorer::BuildStep *CMakeBuildStepFactory::create(ProjectExplorer::Project *project, const QString &name) const
 {
-    Q_ASSERT(name == Constants::CMAKESTEP);
+    QTC_ASSERT(name == Constants::CMAKESTEP, /**/);
     CMakeProject *pro = qobject_cast<CMakeProject *>(project);
-    Q_ASSERT(pro);
+    QTC_ASSERT(pro, /**/);
     return new CMakeStep(pro);
 }
 
diff --git a/src/plugins/cmakeprojectmanager/makestep.cpp b/src/plugins/cmakeprojectmanager/makestep.cpp
index 6bb5b59cdf81833ee87147501c118ae408083753..3cdc0726e8c6ef0271be71f785a18ba2aea463f9 100644
--- a/src/plugins/cmakeprojectmanager/makestep.cpp
+++ b/src/plugins/cmakeprojectmanager/makestep.cpp
@@ -35,18 +35,18 @@
 #include "cmakeprojectconstants.h"
 #include "cmakeproject.h"
 
+#include <utils/qtcassert.h>
+
 using namespace CMakeProjectManager;
 using namespace CMakeProjectManager::Internal;
 
 MakeStep::MakeStep(CMakeProject *pro)
     : AbstractProcessStep(pro), m_pro(pro)
 {
-
 }
 
 MakeStep::~MakeStep()
 {
-
 }
 
 bool MakeStep::init(const QString &buildConfiguration)
@@ -109,9 +109,9 @@ bool MakeBuildStepFactory::canCreate(const QString &name) const
 
 ProjectExplorer::BuildStep *MakeBuildStepFactory::create(ProjectExplorer::Project *project, const QString &name) const
 {
-    Q_ASSERT(name == Constants::MAKESTEP);
+    QTC_ASSERT(name == Constants::MAKESTEP, return 0);
     CMakeProject *pro = qobject_cast<CMakeProject *>(project);
-    Q_ASSERT(pro);
+    QTC_ASSERT(pro, return 0);
     return new MakeStep(pro);
 }
 
diff --git a/src/plugins/coreplugin/basefilewizard.cpp b/src/plugins/coreplugin/basefilewizard.cpp
index 58030ba20c9ad8e0c7aaef03c266ff694fbbc3d6..bb7adb996200a3f4a118d630e7bda6657d2b85b9 100644
--- a/src/plugins/coreplugin/basefilewizard.cpp
+++ b/src/plugins/coreplugin/basefilewizard.cpp
@@ -456,7 +456,7 @@ QStringList BaseFileWizard::runWizard(const QString &path, QWidget *parent)
             }
         }
         if (firstExtensionPageHit)
-            foreach(IFileWizardExtension *ex, extensions)
+            foreach (IFileWizardExtension *ex, extensions)
                 ex->firstExtensionPageShown(files);
         if (accepted)
             break;
@@ -486,7 +486,7 @@ QStringList BaseFileWizard::runWizard(const QString &path, QWidget *parent)
         }
     }
     // Run the extensions
-    foreach(IFileWizardExtension *ex, extensions)
+    foreach (IFileWizardExtension *ex, extensions)
         if (!ex->process(files, &errorMessage)) {
             QMessageBox::critical(parent, tr("File Generation Failure"), errorMessage);
             return QStringList();
diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/src/plugins/coreplugin/dialogs/settingsdialog.cpp
index 696a7ddbdf9ea9d34a8605b69b3cb6c511aafcf4..0f9758b1429e4c19c1ee3943d8831a73ff889693 100644
--- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp
+++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp
@@ -47,6 +47,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory,
     setupUi(this);
     buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
 
+    splitter->setCollapsible(1, false);
     pageTree->header()->setVisible(false);
 
     connect(pageTree, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
@@ -58,8 +59,8 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory,
         CoreImpl::instance()->pluginManager()->getObjects<IOptionsPage>();
 
     int index = 0;
-    foreach(IOptionsPage *page, pages) {
-        QTreeWidgetItem *item = new QTreeWidgetItem();
+    foreach (IOptionsPage *page, pages) {
+        QTreeWidgetItem *item = new QTreeWidgetItem;
         item->setText(0, page->name());
         item->setData(0, Qt::UserRole, index);
 
@@ -77,7 +78,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory,
 
         int catCount = 1;
         while (catCount < categoriesId.count()) {
-            if(!categories.contains(currentCategory + QLatin1Char('|') + categoriesId.at(catCount))) {
+            if (!categories.contains(currentCategory + QLatin1Char('|') + categoriesId.at(catCount))) {
                 treeitem = new QTreeWidgetItem(categories.value(currentCategory));
                 currentCategory +=  QLatin1Char('|') + categoriesId.at(catCount);
                 treeitem->setText(0, trCategories.at(catCount));
@@ -123,14 +124,14 @@ void SettingsDialog::pageSelected(QTreeWidgetItem *)
 
 void SettingsDialog::accept()
 {
-    foreach(IOptionsPage *page, m_pages)
+    foreach (IOptionsPage *page, m_pages)
         page->finished(true);
     done(QDialog::Accepted);
 }
 
 void SettingsDialog::reject()
 {
-    foreach(IOptionsPage *page, m_pages)
+    foreach (IOptionsPage *page, m_pages)
         page->finished(false);
     done(QDialog::Rejected);
 }
diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
index c00e6cc683883334ef1990a919d82417eeeab613..b5c98643b4265539c5e635e98fa0952fbdfa10bd 100644
--- a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
+++ b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
@@ -123,7 +123,7 @@ QWidget *ShortcutSettings::createPage(QWidget *parent)
 void ShortcutSettings::finished(bool accepted)
 {
     if (accepted) {
-        foreach(ShortcutItem *item, m_scitems) {
+        foreach (ShortcutItem *item, m_scitems) {
             item->m_cmd->setKeySequence(item->m_key);
         }
     }
@@ -196,7 +196,7 @@ bool ShortcutSettings::filter(const QString &f, const QTreeWidgetItem *item)
         if (f.isEmpty())
             return false;
         for (int i = 0; i < item->columnCount(); ++i) {
-            if(item->text(i).contains(f, Qt::CaseInsensitive))
+            if (item->text(i).contains(f, Qt::CaseInsensitive))
                 return false;
         }
         return true;
@@ -242,7 +242,7 @@ void ShortcutSettings::importAction()
         CommandsFile cf(fileName);
         QMap<QString, QKeySequence> mapping = cf.importCommands();
 
-        foreach(ShortcutItem *item, m_scitems) {
+        foreach (ShortcutItem *item, m_scitems) {
             QString sid = uidm->stringForUniqueIdentifier(item->m_cmd->id());
             if (mapping.contains(sid)) {
                 item->m_key = mapping.value(sid);
@@ -256,7 +256,7 @@ void ShortcutSettings::importAction()
 
 void ShortcutSettings::defaultAction()
 {
-    foreach(ShortcutItem *item, m_scitems) {
+    foreach (ShortcutItem *item, m_scitems) {
         item->m_key = item->m_cmd->defaultKeySequence();
         item->m_item->setText(2, item->m_key);
         if (item->m_item == m_page->commandList->currentItem())
diff --git a/src/plugins/coreplugin/editormanager/editorgroup.cpp b/src/plugins/coreplugin/editormanager/editorgroup.cpp
index 58c867b02c47af1b5f2ee4f1d9dc7fc74fef16aa..c146a09f25696acb452b77c45a0d7b318e9e32f2 100644
--- a/src/plugins/coreplugin/editormanager/editorgroup.cpp
+++ b/src/plugins/coreplugin/editormanager/editorgroup.cpp
@@ -32,15 +32,18 @@
 ***************************************************************************/
 
 #include "editorgroup.h"
+
 #include "editormanager.h"
 
 #include <coreplugin/coreconstants.h>
+#include <utils/qtcassert.h>
 
 #include <QtCore/QDir>
+#include <QtCore/QDebug>
+
 #include <QtGui/QPainter>
 #include <QtGui/QStyle>
 #include <QtGui/QStyleOption>
-#include <QtCore/QtDebug>
 #ifdef Q_WS_MAC
 #include <QtGui/QMacStyle>
 #endif
@@ -107,20 +110,20 @@ QVariant EditorModel::data(const QModelIndex &index, int role) const
     if (!index.isValid())
         return QVariant();
     IEditor *editor = m_editors.at(index.row());
-    Q_ASSERT(editor);
+    QTC_ASSERT(editor, return QVariant());
     switch (role) {
     case Qt::DisplayRole:
         return editor->file()->isModified()
-                ?editor->displayName()+QLatin1String("*")
-                :editor->displayName();
+                ? editor->displayName() + QLatin1String("*")
+                : editor->displayName();
     case Qt::DecorationRole:
         return editor->file()->isReadOnly()
-                ?QIcon(QLatin1String(":/qworkbench/images/locked.png"))
-                :QIcon();
+                ? QIcon(QLatin1String(":/qworkbench/images/locked.png"))
+                : QIcon();
     case Qt::ToolTipRole:
         return editor->file()->fileName().isEmpty()
-                ?editor->displayName()
-                :QDir::toNativeSeparators(editor->file()->fileName());
+                ? editor->displayName()
+                : QDir::toNativeSeparators(editor->file()->fileName());
     case Qt::UserRole:
         return qVariantFromValue(editor);
     default:
@@ -145,6 +148,7 @@ EditorGroupContext::EditorGroupContext(EditorGroup *editorGroup)
      m_editorGroup(editorGroup)
 {
 }
+
 QList<int> EditorGroupContext::context() const
 {
     return m_context;
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index 29798b25c010e9202f09cd2c27d38e6278ff9900..1b4f04093fdccfe8e74141ab0ae436fa923322ea 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -53,21 +53,23 @@
 #include <coreplugin/baseview.h>
 #include <coreplugin/imode.h>
 
+#include <utils/qtcassert.h>
+
+#include <QtCore/QDebug>
 #include <QtCore/QFileInfo>
-#include <QtCore/QSettings>
 #include <QtCore/QMap>
-#include <QtCore/QSet>
 #include <QtCore/QProcess>
-#include <QtCore/QDebug>
+#include <QtCore/QSet>
+#include <QtCore/QSettings>
 
 #include <QtGui/QAction>
-#include <QtGui/QLayout>
 #include <QtGui/QApplication>
-#include <QtGui/QSplitter>
 #include <QtGui/QFileDialog>
+#include <QtGui/QLayout>
 #include <QtGui/QMenu>
 #include <QtGui/QMessageBox>
 #include <QtGui/QPushButton>
+#include <QtGui/QSplitter>
 
 using namespace Core;
 using namespace Core::Internal;
@@ -961,11 +963,10 @@ bool EditorManager::hasEditor(const QString &fileName) const
 
 void EditorManager::restoreEditorState(IEditor *editor)
 {
-    Q_ASSERT(editor);
+    QTC_ASSERT(editor, return);
     QString fileName = editor->file()->fileName();
-    if (m_d->m_editorStates.contains(fileName)) {
+    if (m_d->m_editorStates.contains(fileName))
         editor->restoreState(m_d->m_editorStates.value(fileName).toByteArray());
-    }
 }
 
 bool EditorManager::saveEditor(IEditor *editor)
@@ -1089,7 +1090,7 @@ bool EditorManager::saveFileAs(IEditor *editor)
     const bool success = editor->file()->save(absoluteFilePath);
     m_d->m_core->fileManager()->unblockFileChange(editor->file());
 
-    if(success)
+    if (success)
         m_d->m_core->fileManager()->addToRecentFiles(editor->file()->fileName());
 
     updateActions();
diff --git a/src/plugins/coreplugin/editormanager/editorsplitter.cpp b/src/plugins/coreplugin/editormanager/editorsplitter.cpp
index f0e7f82bf9aeee996723e110471aada8a32c2bbf..48ec7e0e45a2e568aa8b954bcf6aaaaca4154223 100644
--- a/src/plugins/coreplugin/editormanager/editorsplitter.cpp
+++ b/src/plugins/coreplugin/editormanager/editorsplitter.cpp
@@ -32,16 +32,19 @@
 ***************************************************************************/
 
 #include "editorsplitter.h"
+
 #include "editormanager.h"
+#include "minisplitter.h"
 #include "openeditorswindow.h"
 #include "stackededitorgroup.h"
-#include "minisplitter.h"
 
 #include <coreplugin/icore.h>
 #include <coreplugin/coreconstants.h>
 #include <coreplugin/uniqueidmanager.h>
 #include <coreplugin/actionmanager/actionmanagerinterface.h>
 
+#include <utils/qtcassert.h>
+
 #include <QtGui/QHBoxLayout>
 #include <QtGui/QMenu>
 #include <QtGui/QApplication>
@@ -160,7 +163,7 @@ void EditorSplitter::registerActions()
 void EditorSplitter::updateActions()
 {
     const bool hasMultipleGroups = (qobject_cast<QSplitter*>(m_root) != 0);
-    Q_ASSERT(currentGroup());
+    QTC_ASSERT(currentGroup(), return);
     const bool hasEditors = (currentGroup()->editorCount() != 0);
     m_unsplitAction->setEnabled(hasMultipleGroups);
 #if 0
@@ -245,7 +248,7 @@ void EditorSplitter::collectGroups(QWidget *widget, QList<EditorGroup*> &groups)
         return;
     }
     QSplitter *splitter = qobject_cast<QSplitter*>(widget);
-    Q_ASSERT(splitter);
+    QTC_ASSERT(splitter, return);
     collectGroups(splitter->widget(LEFT), groups);
     collectGroups(splitter->widget(RIGHT), groups);
 }
@@ -330,7 +333,7 @@ void EditorSplitter::unsplit()
     if (!curGroup)
         return;
     QWidget *curGroupWidget = curGroup->widget();
-    Q_ASSERT(curGroupWidget);
+    QTC_ASSERT(curGroupWidget, return);
     IEditor *selectedEditor = curGroup->currentEditor();
 
     QSplitter *parentSplitter = qobject_cast<QSplitter*>(curGroupWidget->parentWidget());
@@ -454,25 +457,25 @@ EditorGroup *EditorSplitter::groupFarthestOnSide(QWidget *node, Side side) const
 void EditorSplitter::selectNextGroup()
 {
     EditorGroup *curGroup = currentGroup();
-    Q_ASSERT(curGroup);
+    QTC_ASSERT(curGroup, return);
     setCurrentGroup(nextGroup(curGroup, RIGHT));
 }
 
 void EditorSplitter::selectPreviousGroup()
 {
     EditorGroup *curGroup = currentGroup();
-    Q_ASSERT(curGroup);
+    QTC_ASSERT(curGroup, return);
     setCurrentGroup(nextGroup(curGroup, LEFT));
 }
 
 EditorGroup *EditorSplitter::nextGroup(EditorGroup *curGroup, Side side) const
 {
-    Q_ASSERT(curGroup);
+    QTC_ASSERT(curGroup, return 0);
     QWidget *curWidget = curGroup->widget();
     QWidget *parent = curWidget->parentWidget();
     while (curWidget != m_root) {
         QSplitter *splitter = qobject_cast<QSplitter *>(parent);
-        Q_ASSERT(splitter);
+        QTC_ASSERT(splitter, return 0);
         if (splitter->widget(side) != curWidget) {
             curWidget = splitter->widget(side);
             break;
@@ -486,7 +489,7 @@ EditorGroup *EditorSplitter::nextGroup(EditorGroup *curGroup, Side side) const
 void EditorSplitter::moveDocToAdjacentGroup(Side side)
 {
     EditorGroup *curGroup = currentGroup();
-    Q_ASSERT(curGroup);
+    QTC_ASSERT(curGroup, return);
     IEditor *editor = curGroup->currentEditor();
     if (!editor)
         return;
@@ -510,7 +513,7 @@ QWidget *EditorSplitter::recreateGroupTree(QWidget *node)
     QSplitter *splitter = qobject_cast<QSplitter *>(node);
     if (!splitter) {
         EditorGroup *group = qobject_cast<EditorGroup *>(node);
-        Q_ASSERT(group);
+        QTC_ASSERT(group, return 0);
         IEditor *currentEditor = group->currentEditor();
         EditorGroup *newGroup = createGroup();
         bool block = newGroup->widget()->blockSignals(true);
@@ -588,7 +591,7 @@ void EditorSplitter::saveState(QWidget *current, QDataStream &stream) const
         saveState(splitter->widget(1), stream);
     } else {
         EditorGroup *group = qobject_cast<EditorGroup *>(current);
-        Q_ASSERT(group);
+        QTC_ASSERT(group, /**/);
         if (group != currentGroup())
             type = 1;
         else
@@ -639,7 +642,7 @@ void EditorSplitter::fillPathGroupMap(QWidget *current, QString currentPath,
         map.insert(currentPath, group);
     } else {
         QSplitter *splitter = qobject_cast<QSplitter *>(current);
-        Q_ASSERT(splitter);
+        QTC_ASSERT(splitter, return);
         fillPathGroupMap(splitter->widget(0), currentPath+"0", map);
         fillPathGroupMap(splitter->widget(1), currentPath+"1", map);
     }
diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp
index 79e912e6e04ee6eae8026e04aecf23c89053e566..8fadf7530642b25341e7b2f891c204104583765d 100644
--- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp
@@ -39,6 +39,7 @@
 #include <coreplugin/coreconstants.h>
 #include <coreplugin/filemanager.h>
 #include <coreplugin/uniqueidmanager.h>
+#include <utils/qtcassert.h>
 
 #include <QtCore/QTimer>
 #include <QtGui/QMenu>
@@ -70,7 +71,7 @@ OpenEditorsWidget::OpenEditorsWidget()
     m_ui.editorList->installEventFilter(this);
     m_ui.editorList->setFrameStyle(QFrame::NoFrame);
     EditorManager *em = EditorManager::instance();
-    foreach(IEditor *editor, em->openedEditors()) {
+    foreach (IEditor *editor, em->openedEditors()) {
         registerEditor(editor);
     }
     connect(em, SIGNAL(editorOpened(Core::IEditor*)),
@@ -197,7 +198,7 @@ void OpenEditorsWidget::selectEditor(QTreeWidgetItem *item)
 void OpenEditorsWidget::updateEditor()
 {
     IEditor *editor = qobject_cast<IEditor *>(sender());
-    Q_ASSERT(editor);
+    QTC_ASSERT(editor, return);
     int num = m_ui.editorList->topLevelItemCount();
     for (int i = 0; i < num; ++i) {
         QTreeWidgetItem *item = m_ui.editorList->topLevelItem(i);
diff --git a/src/plugins/coreplugin/editormanager/stackededitorgroup.cpp b/src/plugins/coreplugin/editormanager/stackededitorgroup.cpp
index 35c4abca29c9c1aa00760bd1df200e45f379e024..c4dcffe91d5e890447d5cf88bd35cda630c20882 100644
--- a/src/plugins/coreplugin/editormanager/stackededitorgroup.cpp
+++ b/src/plugins/coreplugin/editormanager/stackededitorgroup.cpp
@@ -35,21 +35,24 @@
 #include "editormanager.h"
 #include "coreimpl.h"
 
-#include <QtCore/QFileInfo>
+#include <utils/qtcassert.h>
+
+#include <QtCore/QDebug>
 #include <QtCore/QDir>
+#include <QtCore/QFileInfo>
 #include <QtCore/QMimeData>
+
+#include <QtGui/QApplication>
 #include <QtGui/QComboBox>
 #include <QtGui/QHBoxLayout>
+#include <QtGui/QLabel>
+#include <QtGui/QMouseEvent>
 #include <QtGui/QPainter>
+#include <QtGui/QStackedWidget>
 #include <QtGui/QStyle>
 #include <QtGui/QStyleOption>
-#include <QtGui/QMouseEvent>
-#include <QtGui/QApplication>
 #include <QtGui/QToolBar>
 #include <QtGui/QToolButton>
-#include <QtGui/QLabel>
-#include <QtGui/QStackedWidget>
-#include <QtDebug>
 #ifdef Q_WS_MAC
 #include <qmacstyle_mac.h>
 #endif
@@ -240,7 +243,7 @@ void StackedEditorGroup::sendCloseRequest()
 
 void StackedEditorGroup::removeEditor(IEditor *editor)
 {
-    Q_ASSERT(editor);
+    QTC_ASSERT(editor, return);
     EditorGroup::removeEditor(editor);
     const int index = m_container->indexOf(editor->widget());
     if (index != -1) {
@@ -280,7 +283,7 @@ void StackedEditorGroup::setCurrentEditor(IEditor *editor)
         return;
     m_toplevel->setVisible(true);
     const int idx = m_container->indexOf(editor->widget());
-    Q_ASSERT(idx >= 0);
+    QTC_ASSERT(idx >= 0, return);
     if (m_container->currentIndex() != idx) {
         m_container->setCurrentIndex(idx);
 
@@ -298,10 +301,11 @@ void StackedEditorGroup::setCurrentEditor(IEditor *editor)
     }
 }
 
-void StackedEditorGroup::updateEditorStatus(IEditor *editor) {
+void StackedEditorGroup::updateEditorStatus(IEditor *editor)
+{
     if (!editor)
         editor = qobject_cast<IEditor *>(sender());
-    Q_ASSERT(editor);
+    QTC_ASSERT(editor, return);
 
     static const QIcon lockedIcon(QLatin1String(":/qworkbench/images/locked.png"));
     static const QIcon unlockedIcon(QLatin1String(":/qworkbench/images/unlocked.png"));
@@ -371,6 +375,6 @@ int StackedEditorGroup::indexOf(IEditor *editor)
         if (editor == model->data(model->index(i, 0), Qt::UserRole).value<IEditor*>())
             return i;
     }
-    Q_ASSERT(false);
+    QTC_ASSERT(false, /**/);
     return 0;
 }
diff --git a/src/plugins/coreplugin/fileiconprovider.cpp b/src/plugins/coreplugin/fileiconprovider.cpp
index 243e5dd64dee36ea75dc3ee580234051c0c1ad1b..571a49e8ed36ee6dd06d3e2eabec3ab093560ab9 100644
--- a/src/plugins/coreplugin/fileiconprovider.cpp
+++ b/src/plugins/coreplugin/fileiconprovider.cpp
@@ -96,7 +96,7 @@ void FileIconProvider::registerIconForSuffix(const QIcon &icon, const QString &s
 {
     // delete old icon, if it exists
     QList<QPair<QString,QIcon> >::iterator iter = m_cache.begin();
-    for(; iter != m_cache.end(); ++iter) {
+    for (; iter != m_cache.end(); ++iter) {
         if ((*iter).first == suffix) {
             iter = m_cache.erase(iter);
             break;
@@ -118,7 +118,7 @@ QIcon FileIconProvider::iconForSuffix(const QString &suffix) const
         return icon;
 
     QList<QPair<QString,QIcon> >::const_iterator iter = m_cache.constBegin();
-    for(; iter != m_cache.constEnd(); ++iter) {
+    for (; iter != m_cache.constEnd(); ++iter) {
         if ((*iter).first == suffix) {
             icon = (*iter).second;
             break;
diff --git a/src/plugins/coreplugin/filemanager.cpp b/src/plugins/coreplugin/filemanager.cpp
index 9e4e67043806d7e34b371db09f2ac857684a2eec..48ae15dd951ad4c43bcd6d7a5b3772b3a712eb2f 100644
--- a/src/plugins/coreplugin/filemanager.cpp
+++ b/src/plugins/coreplugin/filemanager.cpp
@@ -32,6 +32,7 @@
 ***************************************************************************/
 
 #include "filemanager.h"
+
 #include "ifile.h"
 #include "mainwindow.h"
 #include "saveitemsdialog.h"
@@ -40,6 +41,8 @@
 #include "mimedatabase.h"
 #include "iversioncontrol.h"
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/QDebug>
 #include <QtCore/QSettings>
 #include <QtCore/QFileInfo>
@@ -177,22 +180,20 @@ bool FileManager::removeFile(IFile *file)
 
 void FileManager::addWatch(const QString &filename)
 {
-    if (!filename.isEmpty() && managedFiles(filename).isEmpty()) {
+    if (!filename.isEmpty() && managedFiles(filename).isEmpty())
         m_fileWatcher->addPath(filename);
-    }
 }
 
 void FileManager::removeWatch(const QString &filename)
 {
-    if (!filename.isEmpty() && managedFiles(filename).isEmpty()) {
+    if (!filename.isEmpty() && managedFiles(filename).isEmpty())
         m_fileWatcher->removePath(filename);
-    }
 }
 
 void FileManager::checkForNewFileName()
 {
     IFile *file = qobject_cast<IFile *>(sender());
-    Q_ASSERT(file);
+    QTC_ASSERT(file, return);
     const QString newfilename = fixFileName(file->fileName());
     const QString oldfilename = m_managedFiles.value(file).fileName;
     if (!newfilename.isEmpty() && newfilename != oldfilename) {
diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp
index 1d9050705496bc05501ed25a3a22cec105f034ce..4eab3fb55719566e789044c73362ff4ef7bf711c 100644
--- a/src/plugins/coreplugin/mainwindow.cpp
+++ b/src/plugins/coreplugin/mainwindow.cpp
@@ -896,7 +896,7 @@ void MainWindow::removeContextObject(IContext *context)
         return;
 
     m_contextWidgets.remove(widget);
-    if(m_activeContext == context)
+    if (m_activeContext == context)
         updateContextObject(0);
 }
 
@@ -957,10 +957,11 @@ void MainWindow::resetContext()
     updateContextObject(0);
 }
 
-QMenu *MainWindow::createPopupMenu() {
+QMenu *MainWindow::createPopupMenu()
+{
     QMenu *menu = new QMenu(this);
     QList<ActionContainer *> containers = m_actionManager->containers();
-    foreach(ActionContainer *c, containers) {
+    foreach (ActionContainer *c, containers) {
         if (c->toolBar())
             menu->addAction(c->toolBar()->toggleViewAction());
     }
diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp
index a39e68baad6e165915eed117c8c051d672bfffe3..1b018c66d135ea0e2bca6bb5a6ce8882740c2266 100644
--- a/src/plugins/coreplugin/manhattanstyle.cpp
+++ b/src/plugins/coreplugin/manhattanstyle.cpp
@@ -33,30 +33,34 @@
 
 #include "manhattanstyle.h"
 
-#include <QStyleOption>
-#include <QPainter>
-#include <QScrollArea>
-#include <QMainWindow>
-#include <QDockWidget>
-#include <QPixmapCache>
-#include <QDialogButtonBox>
-#include <QPixmap>
-#include <QToolBar>
-#include <QDialog>
-#include <QLineEdit>
-#include <QComboBox>
-#include <QLibrary>
-#include <QStatusBar>
-#include <QApplication>
-#include <QStyleFactory>
-#include <QToolButton>
-#include <QLabel>
-#include <QPushButton>
-#include <QSplitter>
-#include <QMenuBar>
 #include "stylehelper.h"
 #include "styleanimator.h"
-#include <qdebug.h>
+
+#include <QtCore/QDebug>
+#include <QtCore/QLibrary>
+
+#include <QtGui/QApplication>
+#include <QtGui/QComboBox>
+#include <QtGui/QDialog>
+#include <QtGui/QDialogButtonBox>
+#include <QtGui/QDockWidget>
+#include <QtGui/QLabel>
+#include <QtGui/QLineEdit>
+#include <QtGui/QMainWindow>
+#include <QtGui/QMenuBar>
+#include <QtGui/QPainter>
+#include <QtGui/QPixmap>
+#include <QtGui/QPixmapCache>
+#include <QtGui/QPushButton>
+#include <QtGui/QScrollArea>
+#include <QtGui/QSplitter>
+#include <QtGui/QStatusBar>
+#include <QtGui/QStyleFactory>
+#include <QtGui/QStyleOption>
+#include <QtGui/QToolBar>
+#include <QtGui/QToolButton>
+
+#include <utils/qtcassert.h>
 
 // We define a currently unused state for indicating animations
 #define State_Animating 0x00000040
@@ -97,7 +101,7 @@ public:
     ManhattanStylePrivate(const QString &baseStyleName)
     {
         style = QStyleFactory::create(baseStyleName);
-        Q_ASSERT(style);
+        QTC_ASSERT(style, /**/);
         buttonImage_pressed = QImage(":/qworkbench/images/pushbutton_pressed.png");
         buttonImage = QImage(":/qworkbench/images/pushbutton.png");
 
@@ -105,12 +109,15 @@ public:
         lineeditImage_disabled = QImage(":/qworkbench/images/inputfield_disabled.png");
     }
 
-    ~ManhattanStylePrivate() {
+    ~ManhattanStylePrivate()
+    {
         delete style;
         style = 0;
     }
 
     void init();
+
+public:
     QStyle *style;
     QImage buttonImage;
     QImage buttonImage_pressed;
@@ -140,7 +147,7 @@ void drawCornerImage(const QImage &img, QPainter *painter, QRect rect,
     if (top > 0) { //top
         painter->drawImage(QRect(rect.left() + left, rect.top(), rect.width() -right - left, top), img,
                            QRect(left, 0, size.width() -right - left, top));
-        if(left > 0) //top-left
+        if (left > 0) //top-left
             painter->drawImage(QRect(rect.left(), rect.top(), left, top), img,
                                QRect(0, 0, left, top));
         if (right > 0) //top-right
diff --git a/src/plugins/coreplugin/mimedatabase.cpp b/src/plugins/coreplugin/mimedatabase.cpp
index 0c6d1d4cdde31bfb16d476740a68b5b0c5546139..26e6858c983bf3fb0c3c9bcfbea2729dbe50536b 100644
--- a/src/plugins/coreplugin/mimedatabase.cpp
+++ b/src/plugins/coreplugin/mimedatabase.cpp
@@ -33,19 +33,22 @@
 
 #include "mimedatabase.h"
 
-#include <QtCore/QStringList>
+#include <utils/qtcassert.h>
+
+#include <QtCore/QByteArray>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDebug>
 #include <QtCore/QFile>
+#include <QtCore/QFileInfo>
+#include <QtCore/QLocale>
 #include <QtCore/QMap>
 #include <QtCore/QMultiHash>
-#include <QtCore/QDebug>
 #include <QtCore/QRegExp>
-#include <QtCore/QCoreApplication>
-#include <QtCore/QFileInfo>
-#include <QtCore/QByteArray>
 #include <QtCore/QSharedData>
 #include <QtCore/QSharedPointer>
+#include <QtCore/QStringList>
 #include <QtCore/QTextStream>
-#include <QtCore/QLocale>
+
 #include <QtXml/QXmlStreamReader>
 
 enum { debugMimeDB = 0 };
@@ -299,7 +302,7 @@ void MimeTypeData::debug(QTextStream &str, int indent) const
         str << indentS << "SubClassesOf: " << subClassesOf.join(comma) << '\n';
     if (!globPatterns.empty()) {
         str << indentS << "Glob: ";
-        foreach(const QRegExp &r, globPatterns)
+        foreach (const QRegExp &r, globPatterns)
             str << r.pattern() << ' ';
         str << '\n';
         if (!suffixes.empty()) {
@@ -574,7 +577,7 @@ BaseMimeTypeParser:: BaseMimeTypeParser() :
     // "*.log[1-9]"
     m_suffixPattern(QLatin1String("^\\*\\.[\\w]+$"))
 {
-    Q_ASSERT(m_suffixPattern.isValid());
+    QTC_ASSERT(m_suffixPattern.isValid(), /**/);
 }
 
 void BaseMimeTypeParser::addGlobPattern(const QString &pattern, MimeTypeData *d) const
diff --git a/src/plugins/coreplugin/modemanager.cpp b/src/plugins/coreplugin/modemanager.cpp
index 3ea82b424330782ea714b52e31fec16736b38643..31221a343c241fe39ddb5c1c4a958582d0e698eb 100644
--- a/src/plugins/coreplugin/modemanager.cpp
+++ b/src/plugins/coreplugin/modemanager.cpp
@@ -32,11 +32,13 @@
 ***************************************************************************/
 
 #include "modemanager.h"
+
 #include "fancytabwidget.h"
 #include "fancyactionbar.h"
 #include "mainwindow.h"
 
 #include <aggregation/aggregate.h>
+
 #include <coreplugin/actionmanager/actionmanagerinterface.h>
 #include <coreplugin/actionmanager/icommand.h>
 #include <coreplugin/coreconstants.h>
@@ -44,9 +46,12 @@
 #include <coreplugin/imode.h>
 #include <coreplugin/uniqueidmanager.h>
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/QObject>
 #include <QtCore/QDebug>
 #include <QtCore/QSignalMapper>
+
 #include <QtGui/QAction>
 #include <QtGui/QTabWidget>
 #include <QtGui/QVBoxLayout>
@@ -225,7 +230,7 @@ void ModeManager::currentTabChanged(int index)
 void ModeManager::setFocusToCurrentMode()
 {
     IMode *mode = currentMode();
-    Q_ASSERT(mode);
+    QTC_ASSERT(mode, return);
     QWidget *widget = mode->widget();
     if (widget) {
         QWidget *focusWidget = widget->focusWidget();
diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp
index 5ce8e7498d04f326f4f72c50cd983030a0d14f4a..82ed13a29e8f5d927e37e67de8e4e7df172927a5 100644
--- a/src/plugins/coreplugin/navigationwidget.cpp
+++ b/src/plugins/coreplugin/navigationwidget.cpp
@@ -87,8 +87,8 @@ void NavigationWidgetPlaceHolder::applyStoredSize(int width)
             QList<int> sizes = splitter->sizes();
             int index = splitter->indexOf(this);
             int diff = width - sizes.at(index);
-            int adjust = sizes.count() > 1? ( diff / (sizes.count() - 1)) : 0;
-            for(int i=0; i<sizes.count(); ++i) {
+            int adjust = sizes.count() > 1 ? (diff / (sizes.count() - 1)) : 0;
+            for (int i = 0; i < sizes.count(); ++i) {
                 if (i != index)
                     sizes[i] += adjust;
             }
diff --git a/src/plugins/coreplugin/outputpane.cpp b/src/plugins/coreplugin/outputpane.cpp
index ca60d674ff044382704e1834ed233b8eff0ea1f8..11c0a1c4a0c5f6d771b021827d064d40d121101b 100644
--- a/src/plugins/coreplugin/outputpane.cpp
+++ b/src/plugins/coreplugin/outputpane.cpp
@@ -277,7 +277,7 @@ void OutputPane::init(ICore *core, ExtensionSystem::PluginManager *pm)
 
         connect(cmd->action(), SIGNAL(triggered()), this, SLOT(shortcutTriggered()));
         connect(cmd->action(), SIGNAL(changed()), this, SLOT(updateToolTip()));
-    } while(it != begin);
+    } while (it != begin);
 
     changePage();
 }
@@ -293,7 +293,7 @@ void OutputPane::shortcutTriggered()
         // but the outputpane doesn't have focus
         // then just give it focus
         // else do the same as clicking on the button does
-        if(OutputPanePlaceHolder::m_current
+        if (OutputPanePlaceHolder::m_current
            && OutputPanePlaceHolder::m_current->isVisible()
            && m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() == idx) {
             if (!outputPane->hasFocus() && outputPane->canFocus())
diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp
index e74198d897a3352e5529e9b70131302c927964cd..be851f52677a17a25ab7b6d763f578ac3f9005f9 100644
--- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp
+++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp
@@ -40,11 +40,13 @@
 #include "uniqueidmanager.h"
 #include "viewmanagerinterface.h"
 
+#include <utils/qtcassert.h>
+
 using namespace Core;
 using namespace Core::Internal;
 
-ProgressManager::ProgressManager(QObject *parent) :
-    ProgressManagerInterface(parent)
+ProgressManager::ProgressManager(QObject *parent)
+  : ProgressManagerInterface(parent)
 {
     m_progressView = new ProgressView;
     ICore *core = CoreImpl::instance();
@@ -103,7 +105,7 @@ QWidget *ProgressManager::progressView()
 void ProgressManager::taskFinished()
 {
     QObject *taskObject = sender();
-    Q_ASSERT(taskObject);
+    QTC_ASSERT(taskObject, return);
     QFutureWatcher<void> *task = static_cast<QFutureWatcher<void> *>(taskObject);
     m_runningTasks.remove(task);
     delete task;
diff --git a/src/plugins/coreplugin/progressmanager/progresspie.cpp b/src/plugins/coreplugin/progressmanager/progresspie.cpp
index b6f34d36b41965d12abf5e24d828770d360a6af8..f3aac399709dbd71b66541ef9881ad23dd652c6f 100644
--- a/src/plugins/coreplugin/progressmanager/progresspie.cpp
+++ b/src/plugins/coreplugin/progressmanager/progresspie.cpp
@@ -101,9 +101,9 @@ void ProgressBar::paintEvent(QPaintEvent *)
     double percent = 0.50;
     if (range != 0)
         percent = (value() - minimum()) / range;
-    if(percent > 1)
+    if (percent > 1)
         percent = 1;
-    else if(percent < 0)
+    else if (percent < 0)
         percent = 0;
 
     QPainter p(this);
diff --git a/src/plugins/coreplugin/progressmanager/progressview.cpp b/src/plugins/coreplugin/progressmanager/progressview.cpp
index 274eae8bdb642b7a2074da8808abe1a0f79b0e63..c589b4b689a59ab46b30d30ab01c574aea235135 100644
--- a/src/plugins/coreplugin/progressmanager/progressview.cpp
+++ b/src/plugins/coreplugin/progressmanager/progressview.cpp
@@ -34,6 +34,8 @@
 #include "progressview.h"
 #include "futureprogress.h"
 
+#include <utils/qtcassert.h>
+
 #include <QtGui/QHBoxLayout>
 
 using namespace Core;
@@ -136,7 +138,7 @@ void ProgressView::removeTask(FutureProgress *task)
 void ProgressView::slotFinished()
 {
     FutureProgress *progress = qobject_cast<FutureProgress *>(sender());
-    Q_ASSERT(progress);
+    QTC_ASSERT(progress, return);
     if (m_keep.contains(progress) && !m_keep.value(progress) && !progress->hasError())
         removeTask(progress);
     removeOldTasks(m_type.value(progress), true);
diff --git a/src/plugins/coreplugin/rightpane.cpp b/src/plugins/coreplugin/rightpane.cpp
index 3c17b25583303c6d48db3602f30ee6f70571f688..1465164d1874f9a0eada2b74f3ca9531c8f031ca 100644
--- a/src/plugins/coreplugin/rightpane.cpp
+++ b/src/plugins/coreplugin/rightpane.cpp
@@ -76,8 +76,8 @@ void RightPanePlaceHolder::applyStoredSize(int width)
             QList<int> sizes = splitter->sizes();
             int index = splitter->indexOf(this);
             int diff = width - sizes.at(index);
-            int adjust = sizes.count() > 1? ( diff / (sizes.count() - 1)) : 0;
-            for(int i=0; i<sizes.count(); ++i) {
+            int adjust = sizes.count() > 1 ? (diff / (sizes.count() - 1)) : 0;
+            for (int i = 0; i < sizes.count(); ++i) {
                 if (i != index)
                     sizes[i] -= adjust;
             }
@@ -125,7 +125,7 @@ void RightPanePlaceHolder::currentModeChanged(Core::IMode *mode)
 RightPaneWidget *RightPaneWidget::m_instance = 0;
 
 RightPaneWidget::RightPaneWidget()
-    :m_shown(true), m_width(0)
+    : m_shown(true), m_width(0)
 {
     m_instance = this;
 
diff --git a/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.cpp b/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.cpp
index 28c3c658e66f3ed4dab51a8148b99bb875c51c5f..81e0f77b5644369ae92ffc150cd0e0c26ec71ba0 100644
--- a/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.cpp
+++ b/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.cpp
@@ -38,12 +38,15 @@
 #include <coreplugin/messagemanager.h>
 #include <coreplugin/editormanager/editorgroup.h>
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/QDebug>
 #include <QtCore/QSettings>
 
 #include <QtGui/QMainWindow>
 #include <QtGui/QStatusBar>
 #include <QtGui/QToolBar>
+
 #include <QtScript/QScriptEngine>
 
 namespace {
@@ -107,7 +110,7 @@ QString CorePrototype::toString() const
 CorePrototype::ICore *CorePrototype::callee() const
 {
     ICore *rc = qscriptvalue_cast<ICore *>(thisObject());
-    Q_ASSERT(rc);
+    QTC_ASSERT(rc, return 0);
     return rc;
 }
 
@@ -121,14 +124,14 @@ MessageManagerPrototype::MessageManagerPrototype(QObject *parent) :
 void MessageManagerPrototype::displayStatusBarMessage(const QString &text, int ms)
 {
     MessageManager *mm = qscriptvalue_cast<MessageManager *>(thisObject());
-    Q_ASSERT(mm);
+    QTC_ASSERT(mm, return);
     mm->displayStatusBarMessage(text, ms);
 }
 
 void MessageManagerPrototype::printToOutputPane(const QString &text, bool bringToForeground)
 {
     MessageManager *mm = qscriptvalue_cast<MessageManager *>(thisObject());
-    Q_ASSERT(mm);
+    QTC_ASSERT(mm, return);
     mm->printToOutputPane(text, bringToForeground);
 }
 
@@ -147,28 +150,66 @@ FileManagerPrototype::FileManagerPrototype(QObject *parent) :
 FileManager *FileManagerPrototype::callee() const
 {
     FileManager *rc = qscriptvalue_cast<FileManager *>(thisObject());
-    Q_ASSERT(rc);
+    QTC_ASSERT(rc, return 0);
     return rc;
 }
 
-bool FileManagerPrototype::addFiles(const QList<Core::IFile *> &files) { return callee()->addFiles(files); }
-bool FileManagerPrototype::addFile(Core::IFile *file) { return callee()->addFile(file); }
-bool FileManagerPrototype::removeFile(Core::IFile *file) { return callee()->removeFile(file); }
+bool FileManagerPrototype::addFiles(const QList<Core::IFile *> &files)
+{
+    return callee()->addFiles(files);
+}
+
+bool FileManagerPrototype::addFile(Core::IFile *file)
+{
+    return callee()->addFile(file);
+}
+
+bool FileManagerPrototype::removeFile(Core::IFile *file)
+{
+    return callee()->removeFile(file);
+}
 
 QList<Core::IFile*>
-    FileManagerPrototype::saveModifiedFilesSilently(const QList<Core::IFile*> &files) { return callee()->saveModifiedFilesSilently(files); }
+FileManagerPrototype::saveModifiedFilesSilently(const QList<Core::IFile*> &files)
+{
+    return callee()->saveModifiedFilesSilently(files);
+}
+
+QString FileManagerPrototype::getSaveAsFileName(Core::IFile *file)
+{
+    return callee()->getSaveAsFileName(file);
+}
 
-QString FileManagerPrototype::getSaveAsFileName(Core::IFile *file) { return callee()->getSaveAsFileName(file); }
+bool FileManagerPrototype::isFileManaged(const QString &fileName) const
+{
+    return callee()->isFileManaged(fileName);
+}
 
-bool FileManagerPrototype::isFileManaged(const QString &fileName) const { return callee()->isFileManaged(fileName); }
 QList<Core::IFile *>
-    FileManagerPrototype::managedFiles(const QString &fileName) const { return callee()->managedFiles(fileName); }
+FileManagerPrototype::managedFiles(const QString &fileName) const
+{
+    return callee()->managedFiles(fileName);
+}
 
-void FileManagerPrototype::blockFileChange(Core::IFile *file) { callee()->blockFileChange(file); }
-void FileManagerPrototype::unblockFileChange(Core::IFile *file) { return callee()->unblockFileChange(file); }
+void FileManagerPrototype::blockFileChange(Core::IFile *file)
+{
+    callee()->blockFileChange(file);
+}
+
+void FileManagerPrototype::unblockFileChange(Core::IFile *file)
+{
+    return callee()->unblockFileChange(file);
+}
 
-void FileManagerPrototype::addToRecentFiles(const QString &fileName) { return callee()->addToRecentFiles(fileName); }
-QStringList FileManagerPrototype::recentFiles() const { return callee()->recentFiles(); }
+void FileManagerPrototype::addToRecentFiles(const QString &fileName)
+{
+    return callee()->addToRecentFiles(fileName);
+}
+
+QStringList FileManagerPrototype::recentFiles() const
+{
+    return callee()->recentFiles();
+}
 
 QString FileManagerPrototype::toString() const
 {
@@ -185,7 +226,7 @@ FilePrototype::FilePrototype(QObject *parent) :
 IFile *FilePrototype::callee() const
 {
     IFile *rc = qscriptvalue_cast<IFile *>(thisObject());
-    Q_ASSERT(rc);
+    QTC_ASSERT(rc, return 0);
     return rc;
 }
 
@@ -270,39 +311,66 @@ QString EditorManagerPrototype::toString() const
 EditorManagerPrototype::EditorManager *EditorManagerPrototype::callee() const
 {
     EditorManager *rc = qscriptvalue_cast<EditorManager *>(thisObject());
-    Q_ASSERT(rc);
+    QTC_ASSERT(rc, return 0);
     return rc;
-
 }
 
 // ------------- EditorPrototype
 
-EditorPrototype::EditorPrototype(QObject *parent) :
-    QObject(parent)
+EditorPrototype::EditorPrototype(QObject *parent)
+  : QObject(parent)
 {
 }
 
-QString EditorPrototype::displayName() const { return callee()->displayName(); }
-void EditorPrototype::setDisplayName(const QString &title) { callee()->setDisplayName(title); }
+QString EditorPrototype::displayName() const
+{
+    return callee()->displayName();
+}
 
-QString EditorPrototype::kind() const { return  QLatin1String(callee()->kind()); }
-bool EditorPrototype::duplicateSupported() const { return callee()->duplicateSupported(); }
+void EditorPrototype::setDisplayName(const QString &title)
+{
+    callee()->setDisplayName(title);
+}
 
-bool EditorPrototype::createNew(const QString &contents) { return callee()->createNew(contents); }
-bool EditorPrototype::open(const QString &fileName) { return callee()->open(fileName); }
+QString EditorPrototype::kind() const
+{
+    return  QLatin1String(callee()->kind());
+}
+
+bool EditorPrototype::duplicateSupported() const
+{
+    return callee()->duplicateSupported();
+}
+
+bool EditorPrototype::createNew(const QString &contents)
+{
+    return callee()->createNew(contents);
+}
+
+bool EditorPrototype::open(const QString &fileName)
+{
+    return callee()->open(fileName);
+}
 
 Core::IEditor *EditorPrototype::duplicate(QWidget *parent)
 {
     return callee()->duplicate(parent);
 }
 
-Core::IFile *EditorPrototype::file() const { return callee()->file(); }
-QToolBar* EditorPrototype::toolBar() const { return callee()->toolBar();}
+Core::IFile *EditorPrototype::file() const
+{
+    return callee()->file();
+}
+
+QToolBar* EditorPrototype::toolBar() const
+{
+    return callee()->toolBar();
+}
 
 Core::IEditor *EditorPrototype::callee() const
 {
     IEditor *rc = qscriptvalue_cast<IEditor *>(thisObject());
-    Q_ASSERT(rc);
+    QTC_ASSERT(rc, return 0);
     return rc;
 }
 
@@ -375,7 +443,7 @@ QString EditorGroupPrototype::toString() const
 Core::EditorGroup *EditorGroupPrototype::callee() const
 {
     EditorGroup *rc = qscriptvalue_cast<EditorGroup *>(thisObject());
-    Q_ASSERT(rc);
+    QTC_ASSERT(rc, return 0);
     return rc;
 }
 
diff --git a/src/plugins/coreplugin/scriptmanager/scriptmanager.cpp b/src/plugins/coreplugin/scriptmanager/scriptmanager.cpp
index 5613bd6781a0553aeb24406445dd824fdf0d1109..a3761a17fe13a2b2ba369298a26a632a99acccfc 100644
--- a/src/plugins/coreplugin/scriptmanager/scriptmanager.cpp
+++ b/src/plugins/coreplugin/scriptmanager/scriptmanager.cpp
@@ -36,8 +36,10 @@
 #include "metatypedeclarations.h"
 
 #include <extensionsystem/ExtensionSystemInterfaces>
+#include <utils/qtcassert.h>
 #include <interface_wrap_helpers.h>
 #include <wrap_helpers.h>
+
 #include <limits.h>
 
 #include <QtCore/QDebug>
@@ -154,7 +156,7 @@ static QScriptValue inputDialogGetItem(QScriptContext *context, QScriptEngine *e
 // Script function template to pop up a file box
 // with a certain icon and buttons.
 template <int TAcceptMode, int TFileMode>
-        static QScriptValue fileBox(QScriptContext *context, QScriptEngine *engine)
+static QScriptValue fileBox(QScriptContext *context, QScriptEngine *engine)
 {
     const int argumentCount = context->argumentCount();
     if (argumentCount < 2)
@@ -170,7 +172,7 @@ template <int TAcceptMode, int TFileMode>
     if (fileDialog.exec() == QDialog::Rejected)
         return  QScriptValue(engine, QScriptValue::NullValue);
     const QStringList rc = fileDialog.selectedFiles();
-    Q_ASSERT(!rc.empty());
+    QTC_ASSERT(!rc.empty(), /**/);
     return TFileMode == QFileDialog::ExistingFiles ?
         engine->toScriptValue(rc) : engine->toScriptValue(rc.front());
 }
@@ -249,7 +251,7 @@ void ScriptManager::ensureEngineInitialized()
 {
     if (m_initialized)
         return;
-    Q_ASSERT(m_core);
+    QTC_ASSERT(m_core, return);
     // register QObjects that occur as properties
     SharedTools::registerQObject<QMainWindow>(m_engine);
     SharedTools::registerQObject<QStatusBar>(m_engine);
diff --git a/src/plugins/coreplugin/styleanimator.cpp b/src/plugins/coreplugin/styleanimator.cpp
index e69c48200d0a1c62d968a773e90e7d6c1cb743a0..8ca453278b25c48e632adc039159de078b4b6bec 100644
--- a/src/plugins/coreplugin/styleanimator.cpp
+++ b/src/plugins/coreplugin/styleanimator.cpp
@@ -52,7 +52,8 @@ void Animation::paint(QPainter *painter, const QStyleOption *option)
     Q_UNUSED(painter);
 }
 
-void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) {
+void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha)
+{
     if (_secondaryImage.isNull() || _primaryImage.isNull())
         return;
 
@@ -64,7 +65,7 @@ void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) {
     const int sw = _primaryImage.width();
     const int sh = _primaryImage.height();
     const int bpl = _primaryImage.bytesPerLine();
-    switch(_primaryImage.depth()) {
+    switch (_primaryImage.depth()) {
     case 32:
         {
             uchar *mixed_data = _tempImage.bits();
diff --git a/src/plugins/coreplugin/vcsmanager.cpp b/src/plugins/coreplugin/vcsmanager.cpp
index 02475a0d0e66cfb5369327ec1c5f2827f43aa167..5980879ab1abcff5b7de49b031e0d4827b46d0a1 100644
--- a/src/plugins/coreplugin/vcsmanager.cpp
+++ b/src/plugins/coreplugin/vcsmanager.cpp
@@ -77,7 +77,7 @@ void VCSManager::setVCSEnabled(const QString &directory)
         qDebug() << Q_FUNC_INFO << directory;
     IVersionControl* managingVCS = findVersionControlForDirectory(directory);
     const VersionControlList versionControls = allVersionControls();
-    foreach(IVersionControl *versionControl, versionControls) {
+    foreach (IVersionControl *versionControl, versionControls) {
         const bool newEnabled = versionControl == managingVCS;
         if (newEnabled != versionControl->isEnabled())
             versionControl->setEnabled(newEnabled);
@@ -89,7 +89,7 @@ void VCSManager::setAllVCSEnabled()
     if (debug)
         qDebug() << Q_FUNC_INFO;
     const VersionControlList versionControls = allVersionControls();
-    foreach(IVersionControl *versionControl, versionControls)
+    foreach (IVersionControl *versionControl, versionControls)
         if (!versionControl->isEnabled())
             versionControl->setEnabled(true);
 }
@@ -106,7 +106,7 @@ IVersionControl* VCSManager::findVersionControlForDirectory(const QString &direc
 
     int pos = 0;
     const QChar slash = QLatin1Char('/');
-    while(true) {
+    while (true) {
         int index = directory.indexOf(slash, pos);
         if (index == -1)
             break;
@@ -119,7 +119,7 @@ IVersionControl* VCSManager::findVersionControlForDirectory(const QString &direc
 
     // ah nothing so ask the IVersionControls directly
     const VersionControlList versionControls = allVersionControls();
-    foreach(IVersionControl * versionControl, versionControls) {
+    foreach (IVersionControl * versionControl, versionControls) {
         if (versionControl->managesDirectory(directory)) {
             m_d->m_cachedMatches.insert(versionControl->findTopLevelForDirectory(directory), versionControl);
             return versionControl;
diff --git a/src/plugins/coreplugin/versiondialog.cpp b/src/plugins/coreplugin/versiondialog.cpp
index d2ad590ef693edaf3c0f1f1079db42e4e89c836a..0decae6cf1804dbd980d2e88e217bb2dc13a5850 100644
--- a/src/plugins/coreplugin/versiondialog.cpp
+++ b/src/plugins/coreplugin/versiondialog.cpp
@@ -32,21 +32,25 @@
 ***************************************************************************/
 
 #include "versiondialog.h"
+
 #include "coreconstants.h"
 #include "coreimpl.h"
 
-using namespace Core;
-using namespace Core::Internal;
-using namespace Core::Constants;
+#include <utils/qtcassert.h>
 
 #include <QtCore/QDate>
 #include <QtCore/QFile>
+
+#include <QtGui/QDialogButtonBox>
 #include <QtGui/QGridLayout>
 #include <QtGui/QLabel>
 #include <QtGui/QPushButton>
-#include <QtGui/QDialogButtonBox>
 #include <QtGui/QTextBrowser>
 
+using namespace Core;
+using namespace Core::Internal;
+using namespace Core::Constants;
+
 VersionDialog::VersionDialog(QWidget *parent)
     : QDialog(parent)
 {
@@ -90,7 +94,7 @@ VersionDialog::VersionDialog(QWidget *parent)
 
     QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
     QPushButton *closeButton = buttonBox->button(QDialogButtonBox::Close);
-    Q_ASSERT(closeButton);
+    QTC_ASSERT(closeButton, /**/);
     buttonBox->addButton(closeButton, QDialogButtonBox::ButtonRole(QDialogButtonBox::RejectRole | QDialogButtonBox::AcceptRole));
     connect(buttonBox , SIGNAL(rejected()), this, SLOT(reject()));
 
@@ -118,7 +122,7 @@ void VersionDialog::popupLicense()
 
     // Read file into string
     ICore * core = CoreImpl::instance();
-    Q_ASSERT(core != NULL);
+    QTC_ASSERT(core, return);
     QString fileName = core->resourcePath() + "/license.txt";
     QFile file(fileName);
 
diff --git a/src/plugins/cppeditor/cppclasswizard.cpp b/src/plugins/cppeditor/cppclasswizard.cpp
index 652eec535f18aa4221e7bb1055e780a14a569979..7babfc45ad89a23ce41ed2cf6abb79f072b5143f 100644
--- a/src/plugins/cppeditor/cppclasswizard.cpp
+++ b/src/plugins/cppeditor/cppclasswizard.cpp
@@ -36,12 +36,14 @@
 
 #include <utils/codegeneration.h>
 #include <utils/newclasswidget.h>
+#include <utils/qtcassert.h>
 
-#include <QtCore/QTextStream>
-#include <QtCore/QDir>
 #include <QtCore/QDebug>
-#include <QtGui/QComboBox>
+#include <QtCore/QDir>
+#include <QtCore/QTextStream>
+
 #include <QtGui/QCheckBox>
+#include <QtGui/QComboBox>
 #include <QtGui/QLabel>
 #include <QtGui/QVBoxLayout>
 #include <QtGui/QWizard>
@@ -196,7 +198,7 @@ bool CppClassWizard::generateHeaderAndSource(const CppClassWizardParameters &par
               << "\n#define " <<  guard << '\n' << '\n';
 
     const QRegExp qtClassExpr(QLatin1String("^Q[A-Z3].+"));
-    Q_ASSERT(qtClassExpr.isValid());
+    QTC_ASSERT(qtClassExpr.isValid(), /**/);
     const bool superIsQtClass = qtClassExpr.exactMatch(params.baseClass);
     if (superIsQtClass) {
         Core::Utils::writeIncludeFileDirective(params.baseClass, true, headerStr);
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index ff68bd0bac27e8f9e2c1574ea1f598ae970b9f4e..8d4a36178ce5150221d75c93bbe216532d935dc0 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -520,6 +520,15 @@ void CPPEditor::jumpToDefinition()
 #endif
         }
     } else {
+        foreach (const Document::MacroUse use, doc->macroUses()) {
+            if (use.contains(endOfName - 1)) {
+                const Macro &macro = use.macro();
+                const QString fileName = QString::fromUtf8(macro.fileName);
+                if (TextEditor::BaseTextEditor::openEditorAt(fileName, macro.line, 0))
+                    return; // done
+            }
+        }
+
         qDebug() << "No results for expression:" << expression;
     }
 }
diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp
index d24f5a5f81d167f82836eff5e1f0af9f5bd72ae4..35206c2633b2b057df58f8e1b41c22315d4b9b51 100644
--- a/src/plugins/cpptools/cppcodecompletion.cpp
+++ b/src/plugins/cpptools/cppcodecompletion.cpp
@@ -32,6 +32,7 @@
 ***************************************************************************/
 
 #include "cppcodecompletion.h"
+
 #include "cppmodelmanager.h"
 
 #include <Control.h>
@@ -45,6 +46,7 @@
 #include <SymbolVisitor.h>
 #include <Scope.h>
 #include <TranslationUnit.h>
+
 #include <cplusplus/ResolveExpression.h>
 #include <cplusplus/LookupContext.h>
 #include <cplusplus/Overview.h>
@@ -55,6 +57,7 @@
 #include <coreplugin/editormanager/editormanager.h>
 #include <texteditor/itexteditor.h>
 #include <texteditor/itexteditable.h>
+#include <utils/qtcassert.h>
 #include <texteditor/basetexteditor.h>
 
 #include <QtCore/QDebug>
@@ -540,7 +543,7 @@ bool CppCodeCompletion::completeMember(FullySpecifiedType,
                                        const QList<TypeOfExpression::Result> &results,
                                        const LookupContext &context)
 {
-    Q_ASSERT(! results.isEmpty());
+    QTC_ASSERT(!results.isEmpty(), return false);
 
     QList<Symbol *> classObjectCandidates;
 
@@ -938,7 +941,7 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
     if (m_completionOperator == T_LPAREN) {
         if (symbol) {
             Function *function = symbol->type()->asFunction();
-            Q_ASSERT(function != 0);
+            QTC_ASSERT(function, return);
 
             m_functionArgumentWidget = new FunctionArgumentWidget(m_core);
             m_functionArgumentWidget->showFunctionHint(function);
diff --git a/src/plugins/cpptools/cppfunctionsfilter.cpp b/src/plugins/cpptools/cppfunctionsfilter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..61bb8e2d00d2f66e55a0ce350b82fd6a70bd18e2
--- /dev/null
+++ b/src/plugins/cpptools/cppfunctionsfilter.cpp
@@ -0,0 +1,50 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact:  Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file.  Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception
+** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+
+#include "cppfunctionsfilter.h"
+
+using namespace CppTools::Internal;
+
+CppFunctionsFilter::CppFunctionsFilter(CppModelManager *manager, Core::EditorManager *editorManager)
+    : CppQuickOpenFilter(manager, editorManager)
+{
+    setShortcutString("m");
+    setIncludedByDefault(false);
+
+    search.setSymbolsToSearchFor(SearchSymbols::Functions);
+    search.setSeparateScope(true);
+}
+
+CppFunctionsFilter::~CppFunctionsFilter()
+{
+}
diff --git a/src/plugins/cpptools/cppfunctionsfilter.h b/src/plugins/cpptools/cppfunctionsfilter.h
new file mode 100644
index 0000000000000000000000000000000000000000..6e48d65b26ff0fb3307e2fe645741c2d924c1e97
--- /dev/null
+++ b/src/plugins/cpptools/cppfunctionsfilter.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact:  Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file.  Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception
+** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+
+#ifndef CPPFUNCTIONSFILTER_H
+#define CPPFUNCTIONSFILTER_H
+
+#include <cppquickopenfilter.h>
+
+namespace CppTools {
+namespace Internal {
+
+class CppFunctionsFilter : public CppQuickOpenFilter
+{
+    Q_OBJECT
+
+public:
+    CppFunctionsFilter(CppModelManager *manager, Core::EditorManager *editorManager);
+    ~CppFunctionsFilter();
+
+    QString trName() const { return tr("Methods"); }
+    QString name() const { return QLatin1String("Methods"); }
+    Priority priority() const { return Medium; }
+};
+
+} // namespace Internal
+} // namespace CppTools
+
+#endif // CPPFUNCTIONSFILTER_H
diff --git a/src/plugins/cpptools/cpphoverhandler.cpp b/src/plugins/cpptools/cpphoverhandler.cpp
index 16ed8a9215039009e6d47403939d02d996824f83..338123bc5e65014c344cbad8a45ec98bda125c60 100644
--- a/src/plugins/cpptools/cpphoverhandler.cpp
+++ b/src/plugins/cpptools/cpphoverhandler.cpp
@@ -37,6 +37,7 @@
 #include <coreplugin/icore.h>
 #include <coreplugin/uniqueidmanager.h>
 #include <texteditor/itexteditor.h>
+#include <texteditor/basetexteditor.h>
 #include <debugger/debuggerconstants.h>
 
 #include <CoreTypes.h>
@@ -51,13 +52,13 @@
 #include <cplusplus/TypeOfExpression.h>
 
 #include <QtGui/QToolTip>
-#include <QtGui/QPlainTextEdit>
 #include <QtGui/QTextCursor>
 #include <QtGui/QTextBlock>
 #include <QtHelp/QHelpEngineCore>
 #include <QtCore/QtCore>
 
 using namespace CppTools::Internal;
+using namespace CPlusPlus;
 
 CppHoverHandler::CppHoverHandler(CppModelManager *manager, QObject *parent)
     : QObject(parent), m_manager(manager), m_helpEngineNeedsSetup(false)
@@ -104,11 +105,9 @@ void CppHoverHandler::showToolTip(TextEditor::ITextEditor *editor, const QPoint
     }
 }
 
-static QString buildHelpId(const CPlusPlus::FullySpecifiedType &type,
-                           const CPlusPlus::Symbol *symbol)
+static QString buildHelpId(const FullySpecifiedType &type,
+                           const Symbol *symbol)
 {
-    using namespace CPlusPlus;
-
     Name *name = 0;
     Scope *scope = 0;
 
@@ -156,12 +155,10 @@ static QString buildHelpId(const CPlusPlus::FullySpecifiedType &type,
 
 void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int pos)
 {
-    using namespace CPlusPlus;
-
     m_helpId.clear();
     m_toolTip.clear();
 
-    QPlainTextEdit *edit = qobject_cast<QPlainTextEdit *>(editor->widget());
+    TextEditor::BaseTextEditor *edit = qobject_cast<TextEditor::BaseTextEditor *>(editor->widget());
     if (!edit)
         return;
 
@@ -169,8 +166,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
     tc.setPosition(pos);
 
     const int lineNumber = tc.block().blockNumber() + 1;
-
-    QString fileName = editor->file()->fileName();
+    const QString fileName = editor->file()->fileName();
     Document::Ptr doc = m_manager->document(fileName);
     if (doc) {
         foreach (Document::DiagnosticMessage m, doc->diagnosticMessages()) {
@@ -235,6 +231,16 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
         }
     }
 
+    if (doc && m_toolTip.isEmpty()) {
+        foreach (const Document::MacroUse &use, doc->macroUses()) {
+            if (use.contains(pos)) {
+                m_toolTip = use.macro().toString();
+                m_helpId = use.macro().name;
+                break;
+            }
+        }
+    }
+
     if (m_helpEngineNeedsSetup
         && m_helpEngine->registeredDocumentations().count() > 0) {
         m_helpEngine->setupData();
@@ -243,7 +249,8 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
 
     if (!m_helpId.isEmpty() && !m_helpEngine->linksForIdentifier(m_helpId).isEmpty()) {
         m_toolTip = QString(QLatin1String("<table><tr><td valign=middle><nobr>%1</td>"
-                                          "<td><img src=\":/cpptools/images/f1.svg\"></td></tr></table>")).arg(Qt::escape(m_toolTip));
+                                          "<td><img src=\":/cpptools/images/f1.svg\"></td></tr></table>"))
+                    .arg(Qt::escape(m_toolTip));
         editor->setContextHelpId(m_helpId);
     } else if (!m_toolTip.isEmpty()) {
         m_toolTip = QString(QLatin1String("<nobr>%1")).arg(Qt::escape(m_toolTip));
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index a165614a59479107d72703b33a074a85b70b730c..40888d99f3f770af4f6461e007a6230503ce0eb9 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -52,6 +52,8 @@
 #include <coreplugin/editormanager/editormanager.h>
 #include <coreplugin/progressmanager/progressmanager.h>
 
+#include <utils/qtcassert.h>
+
 #include <TranslationUnit.h>
 #include <Semantic.h>
 #include <AST.h>
@@ -64,10 +66,11 @@
 #include <Lexer.h>
 #include <Token.h>
 
-#include <QPlainTextEdit>
-#include <QMutexLocker>
-#include <QTime>
-#include <QDebug>
+#include <QtCore/QDebug>
+#include <QtCore/QMutexLocker>
+#include <QtCore/QTime>
+
+//#include <QtGui/QPlainTextEdit>
 
 using namespace CppTools;
 using namespace CppTools::Internal;
@@ -299,14 +302,14 @@ void CppPreprocessor::macroAdded(const Macro &macro)
 }
 
 void CppPreprocessor::startExpandingMacro(unsigned offset,
-                                          const Macro &,
+                                          const Macro &macro,
                                           const QByteArray &originalText)
 {
     if (! m_currentDoc)
         return;
 
     //qDebug() << "start expanding:" << macro.name << "text:" << originalText;
-    m_currentDoc->addMacroUse(offset, originalText.length());
+    m_currentDoc->addMacroUse(macro, offset, originalText.length());
 }
 
 void CppPreprocessor::stopExpandingMacro(unsigned, const Macro &)
@@ -387,17 +390,17 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type)
         } else {
             Document::Ptr previousDoc = switchDocument(Document::create(fileName));
 
-            const QByteArray previousFile = env.current_file;
+            const QByteArray previousFile = env.currentFile;
             const unsigned previousLine = env.currentLine;
 
-            env.current_file = QByteArray(m_currentDoc->translationUnit()->fileName(),
-                                          m_currentDoc->translationUnit()->fileNameLength());
+            env.currentFile = QByteArray(m_currentDoc->translationUnit()->fileName(),
+                                         m_currentDoc->translationUnit()->fileNameLength());
 
             QByteArray preprocessedCode;
             m_proc(contents, &preprocessedCode);
             //qDebug() << preprocessedCode;
 
-            env.current_file = previousFile;
+            env.currentFile = previousFile;
             env.currentLine = previousLine;
 
             m_currentDoc->setSource(preprocessedCode);
@@ -439,10 +442,10 @@ CppModelManager::CppModelManager(QObject *parent) :
     m_projectExplorer = ExtensionSystem::PluginManager::instance()
                         ->getObject<ProjectExplorer::ProjectExplorerPlugin>();
 
-    Q_ASSERT(m_projectExplorer);
+    QTC_ASSERT(m_projectExplorer, return);
 
     ProjectExplorer::SessionManager *session = m_projectExplorer->session();
-    Q_ASSERT(session != 0);
+    QTC_ASSERT(session, return);
 
     connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
             this, SLOT(onProjectAdded(ProjectExplorer::Project*)));
@@ -626,7 +629,7 @@ void CppModelManager::editorOpened(Core::IEditor *editor)
 {
     if (isCppEditor(editor)) {
         TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor *>(editor);
-        Q_ASSERT(textEditor != 0);
+        QTC_ASSERT(textEditor, return);
 
         CppEditorSupport *editorSupport = new CppEditorSupport(this);
         editorSupport->setTextEditor(textEditor);
@@ -646,7 +649,7 @@ void CppModelManager::editorAboutToClose(Core::IEditor *editor)
 {
     if (isCppEditor(editor)) {
         TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor *>(editor);
-        Q_ASSERT(textEditor != 0);
+        QTC_ASSERT(textEditor, return);
 
         CppEditorSupport *editorSupport = m_editorSupport.value(textEditor);
         m_editorSupport.remove(textEditor);
@@ -785,7 +788,7 @@ void CppModelManager::parse(QFutureInterface<void> &future,
                             CppPreprocessor *preproc,
                             QStringList files)
 {
-    Q_ASSERT(! files.isEmpty());
+    QTC_ASSERT(!files.isEmpty(), return);
 
     // Change the priority of the background parser thread to idle.
     QThread::currentThread()->setPriority(QThread::IdlePriority);
diff --git a/src/plugins/cpptools/cppquickopenfilter.cpp b/src/plugins/cpptools/cppquickopenfilter.cpp
index a1f1a9b3713e00c76a967d2922dad17875c48034..ac69c9cc6df9119aff415aed84a08e8de54c9ade 100644
--- a/src/plugins/cpptools/cppquickopenfilter.cpp
+++ b/src/plugins/cpptools/cppquickopenfilter.cpp
@@ -75,6 +75,12 @@ void CppQuickOpenFilter::refresh(QFutureInterface<void> &future)
     Q_UNUSED(future);
 }
 
+static bool compareLexigraphically(const QuickOpen::FilterEntry &a,
+                                   const QuickOpen::FilterEntry &b)
+{
+    return a.displayName < b.displayName;
+}
+
 QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &origEntry)
 {
     QString entry = trimWildcards(origEntry);
@@ -109,6 +115,9 @@ QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &orig
         }
     }
 
+    if (entries.size() < 1000)
+        qSort(entries.begin(), entries.end(), compareLexigraphically);
+
     return entries;
 }
 
diff --git a/src/plugins/cpptools/cpptools.cpp b/src/plugins/cpptools/cpptools.cpp
index 957f0cae9b07ed7bf97842baaf316c2dd7bd53a2..5e9f6dca45f2ab3fd333099d4e59822c85bf265c 100644
--- a/src/plugins/cpptools/cpptools.cpp
+++ b/src/plugins/cpptools/cpptools.cpp
@@ -34,6 +34,7 @@
 #include "cpptools.h"
 #include "cppclassesfilter.h"
 #include "cppcodecompletion.h"
+#include "cppfunctionsfilter.h"
 #include "cpphoverhandler.h"
 #include "cppmodelmanager.h"
 #include "cpptoolsconstants.h"
@@ -89,6 +90,7 @@ bool CppToolsPlugin::initialize(const QStringList & /*arguments*/, QString *)
                                                                  m_core->editorManager());
     addAutoReleasedObject(quickOpenFilter);
     addAutoReleasedObject(new CppClassesFilter(m_modelManager, m_core->editorManager()));
+    addAutoReleasedObject(new CppFunctionsFilter(m_modelManager, m_core->editorManager()));
 
     // Menus
     Core::IActionContainer *mtools = am->actionContainer(Core::Constants::M_TOOLS);
diff --git a/src/plugins/cpptools/cpptools.pro b/src/plugins/cpptools/cpptools.pro
index 92905e42ef9af7659dd58358a3fd7c7d50694b3d..74112379e3904c195bdc5431077e08c6ec32a9b2 100644
--- a/src/plugins/cpptools/cpptools.pro
+++ b/src/plugins/cpptools/cpptools.pro
@@ -10,15 +10,16 @@ unix:QMAKE_CXXFLAGS_DEBUG += -O3
 INCLUDEPATH += .
 DEFINES += CPPTOOLS_LIBRARY
 CONFIG += help
-
 HEADERS += cpptools_global.h \
     cppquickopenfilter.h \
     cppclassesfilter.h \
-    searchsymbols.h
+    searchsymbols.h \
+    cppfunctionsfilter.h
 SOURCES += cppquickopenfilter.cpp \
     cpptoolseditorsupport.cpp \
     cppclassesfilter.cpp \
-    searchsymbols.cpp
+    searchsymbols.cpp \
+    cppfunctionsfilter.cpp
 
 # Input
 SOURCES += cpptools.cpp \
diff --git a/src/plugins/cpptools/searchsymbols.cpp b/src/plugins/cpptools/searchsymbols.cpp
index 308449ab581d84738b2c2aff50ae885a6166c78a..2669ea7bc79b70c72f37942faa65d57636a243ac 100644
--- a/src/plugins/cpptools/searchsymbols.cpp
+++ b/src/plugins/cpptools/searchsymbols.cpp
@@ -35,6 +35,7 @@
 
 #include <Literals.h>
 #include <Scope.h>
+#include <Names.h>
 
 using namespace CPlusPlus;
 using namespace CppTools::Internal;
@@ -97,12 +98,24 @@ bool SearchSymbols::visit(Function *symbol)
     if (!(symbolsToSearchFor & Functions))
         return false;
 
+    QString extraScope;
+    if (Name *name = symbol->name()) {
+        if (QualifiedNameId *nameId = name->asQualifiedNameId()) {
+            if (nameId->nameCount() > 1) {
+                extraScope = overview.prettyName(nameId->nameAt(nameId->nameCount() - 2));
+            }
+        }
+    }
+    QString fullScope = _scope;
+    if (!_scope.isEmpty() && !extraScope.isEmpty())
+        fullScope += QLatin1String("::");
+    fullScope += extraScope;
     QString name = symbolName(symbol);
     QString scopedName = scopedSymbolName(name);
     QString type = overview.prettyType(symbol->type(),
-                                       separateScope ? symbol->name() : 0);
+                                       separateScope ? symbol->identity() : 0);
     appendItem(separateScope ? type : scopedName,
-               separateScope ? _scope : type,
+               separateScope ? fullScope : type,
                ModelItemInfo::Method, symbol);
     return false;
 }
@@ -153,7 +166,7 @@ bool SearchSymbols::visit(Class *symbol)
 QString SearchSymbols::scopedSymbolName(const QString &symbolName) const
 {
     QString name = _scope;
-    if (! name.isEmpty())
+    if (!name.isEmpty())
         name += QLatin1String("::");
     name += symbolName;
     return name;
@@ -196,6 +209,9 @@ void SearchSymbols::appendItem(const QString &name,
                                ModelItemInfo::ItemType type,
                                const Symbol *symbol)
 {
+    if (!symbol->name())
+        return;
+
     const QIcon icon = icons.iconForSymbol(symbol);
     items.append(ModelItemInfo(name, info, type,
                                QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),
diff --git a/src/plugins/debugger/attachexternaldialog.cpp b/src/plugins/debugger/attachexternaldialog.cpp
index 1a376b3373ffce4854ddcaa1481a4fcc12e38d53..f5d2101cc95ff8f8c53f6ac19e6e8f8266196667 100644
--- a/src/plugins/debugger/attachexternaldialog.cpp
+++ b/src/plugins/debugger/attachexternaldialog.cpp
@@ -152,13 +152,12 @@ void AttachExternalDialog::rebuildProcessList()
 
 #ifdef Q_OS_WINDOWS
 
-//  Forward declarations:
-BOOL GetProcessList( );
-BOOL ListProcessModules( DWORD dwPID );
-BOOL ListProcessThreads( DWORD dwOwnerPID );
-void printError( TCHAR* msg );
+BOOL GetProcessList();
+BOOL ListProcessModules(DWORD dwPID);
+BOOL ListProcessThreads(DWORD dwOwnerPID);
+void printError(TCHAR *msg);
 
-BOOL GetProcessList( )
+BOOL GetProcessList()
 {
   HANDLE hProcessSnap;
   HANDLE hProcess;
@@ -167,7 +166,7 @@ BOOL GetProcessList( )
 
   // Take a snapshot of all processes in the system.
   hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
-  if( hProcessSnap == INVALID_HANDLE_VALUE )
+  if (hProcessSnap == INVALID_HANDLE_VALUE)
   {
     printError( TEXT("CreateToolhelp32Snapshot (of processes)") );
     return( FALSE );
@@ -178,7 +177,7 @@ BOOL GetProcessList( )
 
   // Retrieve information about the first process,
   // and exit if unsuccessful
-  if( !Process32First( hProcessSnap, &pe32 ) )
+  if (!Process32First( hProcessSnap, &pe32 ))
   {
     printError( TEXT("Process32First") ); // show cause of failure
     CloseHandle( hProcessSnap );          // clean the snapshot object
@@ -196,12 +195,12 @@ BOOL GetProcessList( )
     // Retrieve the priority class.
     dwPriorityClass = 0;
     hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID );
-    if( hProcess == NULL )
+    if (hProcess == NULL)
       printError( TEXT("OpenProcess") );
     else
     {
       dwPriorityClass = GetPriorityClass( hProcess );
-      if( !dwPriorityClass )
+      if (!dwPriorityClass)
         printError( TEXT("GetPriorityClass") );
       CloseHandle( hProcess );
     }
@@ -210,31 +209,30 @@ BOOL GetProcessList( )
     printf( "\n  Thread count      = %d",   pe32.cntThreads );
     printf( "\n  Parent process ID = 0x%08X", pe32.th32ParentProcessID );
     printf( "\n  Priority base     = %d", pe32.pcPriClassBase );
-    if( dwPriorityClass )
+    if (dwPriorityClass)
       printf( "\n  Priority class    = %d", dwPriorityClass );
 
     // List the modules and threads associated with this process
     ListProcessModules( pe32.th32ProcessID );
     ListProcessThreads( pe32.th32ProcessID );
 
-  } while( Process32Next( hProcessSnap, &pe32 ) );
+  } while (Process32Next(hProcessSnap, &pe32));
 
-  CloseHandle( hProcessSnap );
-  return( TRUE );
+  CloseHandle(hProcessSnap);
+  return TRUE;
 }
 
 
-BOOL ListProcessModules( DWORD dwPID )
+BOOL ListProcessModules(DWORD dwPID)
 {
   HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
   MODULEENTRY32 me32;
 
   // Take a snapshot of all modules in the specified process.
   hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwPID );
-  if( hModuleSnap == INVALID_HANDLE_VALUE )
-  {
-    printError( TEXT("CreateToolhelp32Snapshot (of modules)") );
-    return( FALSE );
+  if (hModuleSnap == INVALID_HANDLE_VALUE) {
+    printError(TEXT("CreateToolhelp32Snapshot (of modules)"));
+    return FALSE;
   }
 
   // Set the size of the structure before using it.
@@ -242,7 +240,7 @@ BOOL ListProcessModules( DWORD dwPID )
 
   // Retrieve information about the first module,
   // and exit if unsuccessful
-  if( !Module32First( hModuleSnap, &me32 ) )
+  if (!Module32First( hModuleSnap, &me32))
   {
     printError( TEXT("Module32First") );  // show cause of failure
     CloseHandle( hModuleSnap );           // clean the snapshot object
@@ -261,10 +259,10 @@ BOOL ListProcessModules( DWORD dwPID )
     printf( "\n     Base address   = 0x%08X", (DWORD) me32.modBaseAddr );
     printf( "\n     Base size      = %d",             me32.modBaseSize );
 
-  } while( Module32Next( hModuleSnap, &me32 ) );
+  } while (Module32Next(hModuleSnap, &me32));
 
-  CloseHandle( hModuleSnap );
-  return( TRUE );
+  CloseHandle(hModuleSnap);
+  return TRUE;
 }
 
 BOOL ListProcessThreads( DWORD dwOwnerPID ) 
@@ -274,7 +272,7 @@ BOOL ListProcessThreads( DWORD dwOwnerPID )
  
   // Take a snapshot of all running threads  
   hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 ); 
-  if( hThreadSnap == INVALID_HANDLE_VALUE ) 
+  if (hThreadSnap == INVALID_HANDLE_VALUE) 
     return( FALSE ); 
  
   // Fill in the size of the structure before using it. 
@@ -282,7 +280,7 @@ BOOL ListProcessThreads( DWORD dwOwnerPID )
  
   // Retrieve information about the first thread,
   // and exit if unsuccessful
-  if( !Thread32First( hThreadSnap, &te32 ) ) 
+  if (!Thread32First( hThreadSnap, &te32 )) 
   {
     printError( TEXT("Thread32First") ); // show cause of failure
     CloseHandle( hThreadSnap );          // clean the snapshot object
@@ -294,13 +292,13 @@ BOOL ListProcessThreads( DWORD dwOwnerPID )
   // associated with the specified process
   do 
   { 
-    if( te32.th32OwnerProcessID == dwOwnerPID )
+    if (te32.th32OwnerProcessID == dwOwnerPID)
     {
       printf( "\n\n     THREAD ID      = 0x%08X", te32.th32ThreadID ); 
       printf( "\n     Base priority  = %d", te32.tpBasePri ); 
       printf( "\n     Delta priority = %d", te32.tpDeltaPri ); 
     }
-  } while( Thread32Next(hThreadSnap, &te32 ) ); 
+  } while (Thread32Next(hThreadSnap, &te32)); 
 
   CloseHandle( hThreadSnap );
   return( TRUE );
@@ -308,22 +306,24 @@ BOOL ListProcessThreads( DWORD dwOwnerPID )
 
 void printError( TCHAR* msg )
 {
-  DWORD eNum;
-  TCHAR sysMsg[256];
-  TCHAR* p;
+    DWORD eNum;
+    TCHAR sysMsg[256];
+    TCHAR* p;
 
-  eNum = GetLastError( );
-  FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+    eNum = GetLastError( );
+    FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
          NULL, eNum,
          MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
          sysMsg, 256, NULL );
 
-  // Trim the end of the line and terminate it with a null
-  p = sysMsg;
-  while( ( *p > 31 ) || ( *p == 9 ) )
-    ++p;
-  do { *p-- = 0; } while( ( p >= sysMsg ) &&
-                          ( ( *p == '.' ) || ( *p < 33 ) ) );
+    // Trim the end of the line and terminate it with a null
+    p = sysMsg;
+    while (*p > 31 || *p == 9 )
+        ++p;
+
+    do {
+        *p-- = 0;
+    } while( p >= sysMsg && (*p == '.' || *p < 33));
 
   // Display the message
   _tprintf( TEXT("\n  WARNING: %s failed with error %d (%s)"), msg, eNum, sysMsg );
@@ -331,7 +331,6 @@ void printError( TCHAR* msg )
 
 #endif
 
-
 void AttachExternalDialog::procSelected(const QModelIndex &index0)
 {
     QModelIndex index = index0.sibling(index0.row(), 0);
diff --git a/src/plugins/debugger/attachremotedialog.cpp b/src/plugins/debugger/attachremotedialog.cpp
index 65b02f37f100978739f13b5d999ede99a2b5caea..a409ceba03ac9aa6a1c10195da0e8dfb8dfdb45d 100644
--- a/src/plugins/debugger/attachremotedialog.cpp
+++ b/src/plugins/debugger/attachremotedialog.cpp
@@ -150,10 +150,10 @@ void AttachRemoteDialog::rebuildProcessList()
 #include <stdio.h>
 
 //  Forward declarations:
-BOOL GetProcessList( );
-BOOL ListProcessModules( DWORD dwPID );
-BOOL ListProcessThreads( DWORD dwOwnerPID );
-void printError( TCHAR* msg );
+BOOL GetProcessList();
+BOOL ListProcessModules(DWORD dwPID);
+BOOL ListProcessThreads(DWORD dwOwnerPID);
+void printError(TCHAR* msg);
 
 BOOL GetProcessList( )
 {
@@ -164,7 +164,7 @@ BOOL GetProcessList( )
 
   // Take a snapshot of all processes in the system.
   hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
-  if( hProcessSnap == INVALID_HANDLE_VALUE )
+  if (hProcessSnap == INVALID_HANDLE_VALUE)
   {
     printError( TEXT("CreateToolhelp32Snapshot (of processes)") );
     return( FALSE );
@@ -175,7 +175,7 @@ BOOL GetProcessList( )
 
   // Retrieve information about the first process,
   // and exit if unsuccessful
-  if( !Process32First( hProcessSnap, &pe32 ) )
+  if (!Process32First( hProcessSnap, &pe32 ))
   {
     printError( TEXT("Process32First") ); // show cause of failure
     CloseHandle( hProcessSnap );          // clean the snapshot object
@@ -193,12 +193,12 @@ BOOL GetProcessList( )
     // Retrieve the priority class.
     dwPriorityClass = 0;
     hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID );
-    if( hProcess == NULL )
+    if (hProcess == NULL)
       printError( TEXT("OpenProcess") );
     else
     {
       dwPriorityClass = GetPriorityClass( hProcess );
-      if( !dwPriorityClass )
+      if (!dwPriorityClass)
         printError( TEXT("GetPriorityClass") );
       CloseHandle( hProcess );
     }
@@ -207,7 +207,7 @@ BOOL GetProcessList( )
     printf( "\n  Thread count      = %d",   pe32.cntThreads );
     printf( "\n  Parent process ID = 0x%08X", pe32.th32ParentProcessID );
     printf( "\n  Priority base     = %d", pe32.pcPriClassBase );
-    if( dwPriorityClass )
+    if (dwPriorityClass)
       printf( "\n  Priority class    = %d", dwPriorityClass );
 
     // List the modules and threads associated with this process
@@ -228,7 +228,7 @@ BOOL ListProcessModules( DWORD dwPID )
 
   // Take a snapshot of all modules in the specified process.
   hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwPID );
-  if( hModuleSnap == INVALID_HANDLE_VALUE )
+  if (hModuleSnap == INVALID_HANDLE_VALUE)
   {
     printError( TEXT("CreateToolhelp32Snapshot (of modules)") );
     return( FALSE );
@@ -239,7 +239,7 @@ BOOL ListProcessModules( DWORD dwPID )
 
   // Retrieve information about the first module,
   // and exit if unsuccessful
-  if( !Module32First( hModuleSnap, &me32 ) )
+  if (!Module32First( hModuleSnap, &me32 ))
   {
     printError( TEXT("Module32First") );  // show cause of failure
     CloseHandle( hModuleSnap );           // clean the snapshot object
@@ -271,7 +271,7 @@ BOOL ListProcessThreads( DWORD dwOwnerPID )
  
   // Take a snapshot of all running threads  
   hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 ); 
-  if( hThreadSnap == INVALID_HANDLE_VALUE ) 
+  if (hThreadSnap == INVALID_HANDLE_VALUE) 
     return( FALSE ); 
  
   // Fill in the size of the structure before using it. 
@@ -279,7 +279,7 @@ BOOL ListProcessThreads( DWORD dwOwnerPID )
  
   // Retrieve information about the first thread,
   // and exit if unsuccessful
-  if( !Thread32First( hThreadSnap, &te32 ) ) 
+  if (!Thread32First( hThreadSnap, &te32 )) 
   {
     printError( TEXT("Thread32First") ); // show cause of failure
     CloseHandle( hThreadSnap );          // clean the snapshot object
@@ -291,7 +291,7 @@ BOOL ListProcessThreads( DWORD dwOwnerPID )
   // associated with the specified process
   do 
   { 
-    if( te32.th32OwnerProcessID == dwOwnerPID )
+    if (te32.th32OwnerProcessID == dwOwnerPID)
     {
       printf( "\n\n     THREAD ID      = 0x%08X", te32.th32ThreadID ); 
       printf( "\n     Base priority  = %d", te32.tpBasePri ); 
diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp
index f4b528c50fa9816f896ab3941c062e5f44e0ac2e..e27aa5ec41dd7941e15f6f0bf4ddaeb7114851a4 100644
--- a/src/plugins/debugger/breakhandler.cpp
+++ b/src/plugins/debugger/breakhandler.cpp
@@ -33,9 +33,10 @@
 
 #include "breakhandler.h"
 
-#include "assert.h"
 #include "imports.h" // TextEditor::BaseTextMark
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/QDebug>
 #include <QtCore/QFileInfo>
 
@@ -371,7 +372,7 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const
     static const QIcon icon2(":/gdbdebugger/images/breakpoint_pending.svg");
     static const QString empty = QString(QLatin1Char('-'));
 
-    QWB_ASSERT(mi.isValid(), return QVariant());
+    QTC_ASSERT(mi.isValid(), return QVariant());
 
     if (mi.row() >= size())
         return QVariant();
@@ -550,7 +551,7 @@ void BreakHandler::breakByFunction(const QString &functionName)
     // One per function is enough for now
     for (int index = size(); --index >= 0;) {
         const BreakpointData *data = at(index);
-        QWB_ASSERT(data, break);
+        QTC_ASSERT(data, break);
         if (data->funcName == functionName && data->condition.isEmpty()
                 && data->ignoreCount.isEmpty())
             return;
diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro
index d21eb7cdc01dfa98f4349dfc48df2904c041a13f..3d67e19c6aae2337f008e5416c5d18d99ba5c729 100644
--- a/src/plugins/debugger/debugger.pro
+++ b/src/plugins/debugger/debugger.pro
@@ -13,8 +13,7 @@ include(../../libs/cplusplus/cplusplus.pri)
 # DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII
 QT += gui network script
 
-HEADERS += assert.h \
-    attachexternaldialog.h \
+HEADERS += attachexternaldialog.h \
     attachremotedialog.h \
     breakhandler.h \
     breakwindow.h \
diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp
index 11e7ef6c82d1512f05751c13b64baab04f2ebfdd..a01a3ddc57e0d81e136e2945c7bdc8ed5e520ad7 100644
--- a/src/plugins/debugger/debuggermanager.cpp
+++ b/src/plugins/debugger/debuggermanager.cpp
@@ -352,6 +352,15 @@ void DebuggerManager::init()
     m_useFastStartAction->setCheckable(true);
     m_useFastStartAction->setChecked(true);
 
+    m_useToolTipsAction = new QAction(this);
+    m_useToolTipsAction->setText(tr("Use Tooltips While Debugging"));
+    m_useToolTipsAction->setToolTip(tr("Checking this will make enable "
+        "tooltips for variable values during debugging. Since this can slow "
+        "down debugging and does not provide reliable information as it does "
+        "not use scope information, it is switched off by default."));
+    m_useToolTipsAction->setCheckable(true);
+    m_useToolTipsAction->setChecked(false);
+
     // FIXME
     m_useFastStartAction->setChecked(false);
     m_useFastStartAction->setEnabled(false);
@@ -943,6 +952,8 @@ void DebuggerManager::loadSessionData()
     QVariant value;
     querySessionValue(QLatin1String("UseFastStart"), &value);
     m_useFastStartAction->setChecked(value.toBool());
+    querySessionValue(QLatin1String("UseToolTips"), &value);
+    m_useToolTipsAction->setChecked(value.toBool());
     querySessionValue(QLatin1String("UseCustomDumpers"), &value);
     m_useCustomDumpersAction->setChecked(!value.isValid() || value.toBool());
     querySessionValue(QLatin1String("SkipKnownFrames"), &value);
@@ -956,6 +967,8 @@ void DebuggerManager::saveSessionData()
 
     setSessionValue(QLatin1String("UseFastStart"),
         m_useFastStartAction->isChecked());
+    setSessionValue(QLatin1String("UseToolTips"),
+        m_useToolTipsAction->isChecked());
     setSessionValue(QLatin1String("UseCustomDumpers"),
         m_useCustomDumpersAction->isChecked());
     setSessionValue(QLatin1String("SkipKnownFrames"),
diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h
index 63c225411fcc2e2063c589e1b287d11655253e5c..64dee6957f732c73400e83072b9f75e4023218db 100644
--- a/src/plugins/debugger/debuggermanager.h
+++ b/src/plugins/debugger/debuggermanager.h
@@ -308,6 +308,7 @@ private:
     ThreadsHandler *threadsHandler() { return m_threadsHandler; }
     WatchHandler *watchHandler() { return m_watchHandler; }
     QAction *useCustomDumpersAction() const { return m_useCustomDumpersAction; }
+    QAction *useToolTipsAction() const { return m_useToolTipsAction; }
     QAction *debugDumpersAction() const { return m_debugDumpersAction; }
     bool skipKnownFrames() const;
     bool debugDumpers() const;
@@ -431,6 +432,7 @@ private:
     QAction *m_debugDumpersAction;
     QAction *m_useCustomDumpersAction;
     QAction *m_useFastStartAction;
+    QAction *m_useToolTipsAction;
     QAction *m_dumpLogAction;
 
     QWidget *m_breakWindow;
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index feb63fa0c306da890538993d03b4871526d425e2..37406f70cc1a6678e9506c75d320adea5711d544 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -33,7 +33,6 @@
 
 #include "debuggerplugin.h"
 
-#include "assert.h"
 #include "debuggerconstants.h"
 #include "debuggermanager.h"
 #include "debuggerrunner.h"
@@ -48,20 +47,27 @@
 #include <coreplugin/messagemanager.h>
 #include <coreplugin/modemanager.h>
 #include <coreplugin/uniqueidmanager.h>
+
 #include <cplusplus/ExpressionUnderCursor.h>
+
 #include <cppeditor/cppeditorconstants.h>
+
 #include <projectexplorer/projectexplorerconstants.h>
 #include <projectexplorer/session.h>
+
+#include <texteditor/basetexteditor.h>
 #include <texteditor/basetextmark.h>
 #include <texteditor/itexteditor.h>
 #include <texteditor/texteditorconstants.h>
-#include <texteditor/basetexteditor.h>
+
+#include <utils/qtcassert.h>
 
 #include <QtCore/QDebug>
 #include <QtCore/qplugin.h>
 #include <QtCore/QObject>
 #include <QtCore/QPoint>
 #include <QtCore/QSettings>
+
 #include <QtGui/QPlainTextEdit>
 #include <QtGui/QTextBlock>
 #include <QtGui/QTextCursor>
@@ -91,6 +97,7 @@ const char * const DEBUG_DUMPERS        = "Debugger.DebugDumpers";
 const char * const ADD_TO_WATCH         = "Debugger.AddToWatch";
 const char * const USE_CUSTOM_DUMPERS   = "Debugger.UseCustomDumpers";
 const char * const USE_FAST_START       = "Debugger.UseFastStart";
+const char * const USE_TOOL_TIPS        = "Debugger.UseToolTips";
 const char * const SKIP_KNOWN_FRAMES    = "Debugger.SkipKnownFrames";
 const char * const DUMP_LOG             = "Debugger.DumpLog";
 
@@ -188,7 +195,7 @@ void DebuggerPlugin::shutdown()
 {
     if (m_debugMode)
         m_debugMode->shutdown(); // saves state including manager information
-    QWB_ASSERT(m_manager, /**/);
+    QTC_ASSERT(m_manager, /**/);
     if (m_manager)
         m_manager->shutdown();
 
@@ -225,13 +232,13 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes
     m_pm = ExtensionSystem::PluginManager::instance();
 
     ICore *core = m_pm->getObject<Core::ICore>();
-    QWB_ASSERT(core, return false);
+    QTC_ASSERT(core, return false);
 
     Core::ActionManagerInterface *actionManager = core->actionManager();
-    QWB_ASSERT(actionManager, return false);
+    QTC_ASSERT(actionManager, return false);
 
     Core::UniqueIDManager *uidm = core->uniqueIDManager();
-    QWB_ASSERT(uidm, return false);
+    QTC_ASSERT(uidm, return false);
 
     QList<int> globalcontext;
     globalcontext << Core::Constants::C_GLOBAL_ID;
@@ -374,13 +381,17 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes
         Constants::USE_FAST_START, globalcontext);
     mdebug->addAction(cmd);
 
+    cmd = actionManager->registerAction(m_manager->m_useToolTipsAction,
+        Constants::USE_TOOL_TIPS, globalcontext);
+    mdebug->addAction(cmd);
+
+#ifdef QT_DEBUG
     cmd = actionManager->registerAction(m_manager->m_dumpLogAction,
         Constants::DUMP_LOG, globalcontext);
     //cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+D,Ctrl+L")));
     cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F11")));
     mdebug->addAction(cmd);
 
-#ifdef QT_DEBUG
     cmd = actionManager->registerAction(m_manager->m_debugDumpersAction,
         Constants::DEBUG_DUMPERS, debuggercontext);
     mdebug->addAction(cmd);
@@ -549,6 +560,9 @@ void DebuggerPlugin::requestMark(TextEditor::ITextEditor *editor, int lineNumber
 void DebuggerPlugin::showToolTip(TextEditor::ITextEditor *editor,
     const QPoint &point, int pos)
 {
+    if (!m_manager->useToolTipsAction()->isChecked())
+        return;
+
     QPlainTextEdit *plaintext = qobject_cast<QPlainTextEdit*>(editor->widget());
     if (!plaintext)
         return;
@@ -590,13 +604,13 @@ void DebuggerPlugin::querySessionValue(const QString &name, QVariant *value)
 
 void DebuggerPlugin::setConfigValue(const QString &name, const QVariant &value)
 {
-    QWB_ASSERT(m_debugMode, return);
+    QTC_ASSERT(m_debugMode, return);
     m_debugMode->settings()->setValue(name, value);
 }
 
 void DebuggerPlugin::queryConfigValue(const QString &name, QVariant *value)
 {
-    QWB_ASSERT(m_debugMode, return);
+    QTC_ASSERT(m_debugMode, return);
     *value = m_debugMode->settings()->value(name);
 }
 
diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp
index 90c8c4e9f7d6dc53acf6bfe7dfcbc415b596b0e1..ddf21ad652ef7d9f8ec4627a19649376436dafe0 100644
--- a/src/plugins/debugger/debuggerrunner.cpp
+++ b/src/plugins/debugger/debuggerrunner.cpp
@@ -33,7 +33,6 @@
 
 #include "debuggerrunner.h"
 
-#include "assert.h"
 #include "debuggermanager.h"
 
 #include <projectexplorer/applicationrunconfiguration.h>
@@ -41,9 +40,12 @@
 #include <projectexplorer/project.h>
 #include <projectexplorer/projectexplorerconstants.h>
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/QDebug>
 #include <QtCore/QDir>
 #include <QtCore/QFileInfo>
+
 #include <QtGui/QTextDocument>
 
 using namespace Debugger::Internal;
@@ -76,11 +78,10 @@ QString DebuggerRunner::displayName() const
 
 RunControl* DebuggerRunner::run(RunConfigurationPtr runConfiguration, const QString &mode)
 {
-    Q_UNUSED(mode);
-    Q_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE);
+    QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0);
     ApplicationRunConfigurationPtr rc =
         qSharedPointerCast<ApplicationRunConfiguration>(runConfiguration);
-    Q_ASSERT(rc);
+    QTC_ASSERT(rc, return 0);
     //qDebug() << "***** Debugging" << rc->name() << rc->executable();
     return new DebuggerRunControl(m_manager, rc);
 }
@@ -118,9 +119,9 @@ void DebuggerRunControl::start()
     m_running = true;
     ApplicationRunConfigurationPtr rc =
         qSharedPointerCast<ApplicationRunConfiguration>(runConfiguration());
-    QWB_ASSERT(rc, return);
+    QTC_ASSERT(rc, return);
     ProjectExplorer::Project *project = rc->project();
-    QWB_ASSERT(project, return);
+    QTC_ASSERT(project, return);
 
     m_manager->m_executable = rc->executable();
     m_manager->m_environment = rc->environment().toStringList();
diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp
index f1042c4faf5e488a8fe97d397f5cee0fb2dc9d5b..d7ac5b1aaa1b4897e1c51bcdcb415aefc75ec271 100644
--- a/src/plugins/debugger/gdbengine.cpp
+++ b/src/plugins/debugger/gdbengine.cpp
@@ -33,7 +33,6 @@
 
 #include "gdbengine.h"
 
-#include "assert.h"
 #include "debuggerconstants.h"
 #include "debuggermanager.h"
 #include "gdbmi.h"
@@ -49,6 +48,8 @@
 #include "startexternaldialog.h"
 #include "attachexternaldialog.h"
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/QDebug>
 #include <QtCore/QDir>
 #include <QtCore/QFileInfo>
@@ -278,25 +279,8 @@ void GdbEngine::init()
     connect(&m_gdbProc, SIGNAL(finished(int, QProcess::ExitStatus)), q,
         SLOT(exitDebugger()));
 
-    // Custom dumpers
-    //m_dumperServerConnection = 0;
-    //m_dumperServer = new DumperServer(this);
-    //QString name = "gdb-" +
-    //    QDateTime::currentDateTime().toString("yyyy_MM_dd-hh_mm_ss_zzz");
-    //m_dumperServer->listen(name);
-    //connect(m_dumperServer, SIGNAL(newConnection()),
-    //   this, SLOT(acceptConnection()));
-
-    //if (!m_dumperServer->isListening()) {
-    //    QMessageBox::critical(q->mainWindow(), tr("Dumper Server Setup Failed"),
-    //      tr("Unable to create server listening for data: %1.\n"
-    //         "Server name: %2").arg(m_dumperServer->errorString(), name),
-    //      QMessageBox::Retry | QMessageBox::Cancel);
-   // }
-
     connect(qq->debugDumpersAction(), SIGNAL(toggled(bool)),
         this, SLOT(setDebugDumpers(bool)));
-
     connect(qq->useCustomDumpersAction(), SIGNAL(toggled(bool)),
         this, SLOT(setCustomDumpersWanted(bool)));
 
@@ -442,8 +426,7 @@ void GdbEngine::handleResponse()
             break;
         }
 
-        if (token == -1 && *from != '&' && *from != '~' && *from != '*'
-            && *from != '=') {
+        if (token == -1 && *from != '&' && *from != '~' && *from != '*') {
             // FIXME: On Linux the application's std::out is merged in here.
             // High risk of falsely interpreting this as MI output.
             // We assume that we _always_ use tokens, so not finding a token
@@ -452,7 +435,7 @@ void GdbEngine::handleResponse()
             while (from != to && *from != '\n')
                 s += *from++;
             //qDebug() << "UNREQUESTED DATA " << s << " TAKEN AS APPLICATION OUTPUT";
-            s += '\n';
+            //s += '\n';
 
             m_inbuffer = QByteArray(from, to - from);
             emit applicationOutputAvailable("app-stdout: ", s);
@@ -648,7 +631,7 @@ void GdbEngine::readGdbStandardOutput()
     #endif
 
     m_inbuffer.append(out);
-    //QWB_ASSERT(!m_inbuffer.isEmpty(), return);
+    //QTC_ASSERT(!m_inbuffer.isEmpty(), return);
 
     char c = m_inbuffer[m_inbuffer.size() - 1];
     static const QByteArray termArray("(gdb) ");
@@ -1416,7 +1399,7 @@ void GdbEngine::handleFileExecAndSymbols
         QString msg = response.data.findChild("msg").data();
         QMessageBox::critical(q->mainWindow(), tr("Error"),
             tr("Starting executable failed:\n") + msg);
-        QWB_ASSERT(q->status() == DebuggerInferiorRunning, /**/);
+        QTC_ASSERT(q->status() == DebuggerInferiorRunning, /**/);
         interruptInferior();
     }
 }
@@ -1437,7 +1420,7 @@ void GdbEngine::handleExecRun(const GdbResultRecord &response)
         } else {
             QMessageBox::critical(q->mainWindow(), tr("Error"),
                 tr("Starting executable failed:\n") + msg);
-            QWB_ASSERT(q->status() == DebuggerInferiorRunning, /**/);
+            QTC_ASSERT(q->status() == DebuggerInferiorRunning, /**/);
             interruptInferior();
         }
     }
@@ -2432,7 +2415,7 @@ void GdbEngine::selectThread(int index)
     threadsHandler->setCurrentThread(index);
 
     QList<ThreadData> threads = threadsHandler->threads();
-    QWB_ASSERT(index < threads.size(), return);
+    QTC_ASSERT(index < threads.size(), return);
     int id = threads.at(index).id;
     q->showStatusMessage(tr("Retrieving data for stack view..."), 10000);
     sendCommand(QLatin1String("-thread-select ") + QString::number(id),
@@ -2449,7 +2432,7 @@ void GdbEngine::activateFrame(int frameIndex)
     //qDebug() << "ACTIVATE FRAME: " << frameIndex << oldIndex
     //    << stackHandler->currentIndex();
 
-    QWB_ASSERT(frameIndex < stackHandler->stackSize(), return);
+    QTC_ASSERT(frameIndex < stackHandler->stackSize(), return);
 
     if (oldIndex != frameIndex) {
         // Assuming this always succeeds saves a roundtrip.
@@ -2970,7 +2953,7 @@ bool GdbEngine::isCustomValueDumperAvailable(const QString &type) const
 void GdbEngine::runCustomDumper(const WatchData & data0, bool dumpChildren)
 {
     WatchData data = data0;
-    QWB_ASSERT(!data.exp.isEmpty(), return);
+    QTC_ASSERT(!data.exp.isEmpty(), return);
     QString tmplate;
     QString inner;
     bool isTemplate = extractTemplate(data.type, &tmplate, &inner);
@@ -3111,7 +3094,7 @@ void GdbEngine::updateSubItem(const WatchData &data0)
     #if DEBUG_SUBITEM
     qDebug() << "UPDATE SUBITEM: " << data.toString();
     #endif
-    QWB_ASSERT(data.isValid(), return);
+    QTC_ASSERT(data.isValid(), return);
 
     // in any case we need the type first
     if (data.isTypeNeeded()) {
@@ -3139,7 +3122,7 @@ void GdbEngine::updateSubItem(const WatchData &data0)
     }
 
     // we should have a type now. this is relied upon further below
-    QWB_ASSERT(!data.type.isEmpty(), return);
+    QTC_ASSERT(!data.type.isEmpty(), return);
 
     // a common case that can be easily solved
     if (data.isChildrenNeeded() && isPointerType(data.type)
@@ -3197,7 +3180,7 @@ void GdbEngine::updateSubItem(const WatchData &data0)
     }
 
     if (data.isValueNeeded()) {
-        QWB_ASSERT(!data.variable.isEmpty(), return); // tested above
+        QTC_ASSERT(!data.variable.isEmpty(), return); // tested above
         #if DEBUG_SUBITEM
         qDebug() << "UPDATE SUBITEM: VALUE";
         #endif
@@ -3226,7 +3209,7 @@ void GdbEngine::updateSubItem(const WatchData &data0)
     }
 
     if (data.isChildrenNeeded()) {
-        QWB_ASSERT(!data.variable.isEmpty(), return); // tested above
+        QTC_ASSERT(!data.variable.isEmpty(), return); // tested above
         QString cmd = "-var-list-children --all-values \"" + data.variable + "\"";
         sendSynchronizedCommand(cmd, WatchVarListChildren, QVariant::fromValue(data));
         return;
@@ -3251,14 +3234,14 @@ void GdbEngine::updateSubItem(const WatchData &data0)
     }
 
     if (data.isChildCountNeeded()) {
-        QWB_ASSERT(!data.variable.isEmpty(), return); // tested above
+        QTC_ASSERT(!data.variable.isEmpty(), return); // tested above
         QString cmd = "-var-list-children --all-values \"" + data.variable + "\"";
         sendCommand(cmd, WatchVarListChildren, QVariant::fromValue(data));
         return;
     }
 
     qDebug() << "FIXME: UPDATE SUBITEM: " << data.toString();
-    QWB_ASSERT(false, return);
+    QTC_ASSERT(false, return);
 }
 
 void GdbEngine::updateWatchModel()
@@ -3272,7 +3255,7 @@ void GdbEngine::updateWatchModel2()
 {
     PENDING_DEBUG("UPDATE WATCH MODEL");
     QList<WatchData> incomplete = qq->watchHandler()->takeCurrentIncompletes();
-    //QWB_ASSERT(incomplete.isEmpty(), /**/);
+    //QTC_ASSERT(incomplete.isEmpty(), /**/);
     if (!incomplete.isEmpty()) {
         #if DEBUG_PENDING
         qDebug() << "##############################################";
@@ -3437,7 +3420,7 @@ void GdbEngine::handleEvaluateExpression(const GdbResultRecord &record,
     const WatchData &data0)
 {
     WatchData data = data0;
-    QWB_ASSERT(data.isValid(), qDebug() << "HUH?");
+    QTC_ASSERT(data.isValid(), qDebug() << "HUH?");
     if (record.resultClass == GdbResultDone) {
         //if (col == 0)
         //    data.name = record.data.findChild("value").data();
@@ -3465,7 +3448,7 @@ void GdbEngine::handleDumpCustomValue1(const GdbResultRecord &record,
     const WatchData &data0)
 {
     WatchData data = data0;
-    QWB_ASSERT(data.isValid(), return);
+    QTC_ASSERT(data.isValid(), return);
     if (record.resultClass == GdbResultDone) {
         // ignore this case, data will follow
     } else if (record.resultClass == GdbResultError) {
@@ -3499,7 +3482,7 @@ void GdbEngine::handleDumpCustomValue2(const GdbResultRecord &record,
     const WatchData &data0)
 {
     WatchData data = data0;
-    QWB_ASSERT(data.isValid(), return);
+    QTC_ASSERT(data.isValid(), return);
     //qDebug() << "CUSTOM VALUE RESULT: " << record.toString();
     //qDebug() << "FOR DATA: " << data.toString() << record.resultClass;
     if (record.resultClass == GdbResultDone) {
@@ -3660,10 +3643,20 @@ void GdbEngine::setLocals(const QList<GdbMi> &locals)
     QHash<QString, int> seen;
 
     foreach (const GdbMi &item, locals) {
+        // Local variables of inlined code are reported as 
+        // 26^done,locals={varobj={exp="this",value="",name="var4",exp="this",
+        // numchild="1",type="const QtSharedPointer::Basic<CPlusPlus::..."
+        // We do not want these at all. Current hypotheses is that those
+        // "spurious" locals have _two_ "exp" field. Try to filter them:
         #ifdef Q_OS_MAC
-            QString name = item.findChild("exp").data();
+        int numExps = 0;
+        foreach (const GdbMi &child, item.children())
+            numExps += int(child.name() == "exp");
+        if (numExps > 1)
+            continue;
+        QString name = item.findChild("exp").data();
         #else
-            QString name = item.findChild("name").data();
+        QString name = item.findChild("name").data();
         #endif
         int n = seen.value(name);
         if (n) {
diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h
index b3e13233526754ac0d0c41bec3992bd668f19913..56106a7524468e7270340462f80df9e1a88a02ff 100644
--- a/src/plugins/debugger/gdbengine.h
+++ b/src/plugins/debugger/gdbengine.h
@@ -34,6 +34,9 @@
 #ifndef DEBUGGER_GDBENGINE_H
 #define DEBUGGER_GDBENGINE_H
 
+#include "idebuggerengine.h"
+#include "gdbmi.h"
+
 #include <QtCore/QByteArray>
 #include <QtCore/QHash>
 #include <QtCore/QMap>
@@ -48,9 +51,6 @@ class QAbstractItemModel;
 class QWidget;
 QT_END_NAMESPACE
 
-#include "idebuggerengine.h"
-#include "gdbmi.h"
-
 namespace Debugger {
 namespace Internal {
 
diff --git a/src/plugins/debugger/gdbmi.cpp b/src/plugins/debugger/gdbmi.cpp
index ff976eff798978694e9acf0db461b19ecd4f12de..f14bb752e3e94f8e6b246c13988554cc697d5353 100644
--- a/src/plugins/debugger/gdbmi.cpp
+++ b/src/plugins/debugger/gdbmi.cpp
@@ -32,10 +32,10 @@
 ***************************************************************************/
 
 #include "gdbmi.h"
-#include "assert.h"
+
+#include <utils/qtcassert.h>
 
 #include <QtCore/QByteArray>
-#include <QtCore/QDebug>
 #include <QtCore/QTextStream>
 
 namespace Debugger {
@@ -138,7 +138,7 @@ void GdbMi::parseValue(const Char *&from, const Char *to)
 void GdbMi::parseTuple(const Char *&from, const Char *to)
 {
     //qDebug() << "parseTuple: " << QByteArray::fromUtf16(from, to - from);
-    QWB_ASSERT(*from == '{', /**/);
+    QTC_ASSERT(*from == '{', /**/);
     ++from;
     parseTuple_helper(from, to);
 }
@@ -166,7 +166,7 @@ void GdbMi::parseTuple_helper(const Char *&from, const Char *to)
 void GdbMi::parseList(const Char *&from, const Char *to)
 {
     //qDebug() << "parseList: " << QByteArray::fromUtf16(from, to - from);
-    QWB_ASSERT(*from == '[', /**/);
+    QTC_ASSERT(*from == '[', /**/);
     ++from;
     m_type = List;
     while (from < to) {
diff --git a/src/plugins/debugger/gdbtypemacros.cpp b/src/plugins/debugger/gdbtypemacros.cpp
index a445a336324a302c73cf39670db33cb6d2ad3749..8610d01e39d87c2c9a64ff84cbf1389a74fc11bd 100644
--- a/src/plugins/debugger/gdbtypemacros.cpp
+++ b/src/plugins/debugger/gdbtypemacros.cpp
@@ -59,10 +59,10 @@ TypeMacroPage::TypeMacroPage(GdbSettings *settings)
         //insert qt4 defaults
         m_settings->m_scriptFile = coreIFace->resourcePath() +
             QLatin1String("/gdb/qt4macros");
-        for (int i=0; i<3; ++i) {
+        for (int i = 0; i < 3; ++i) {
             QByteArray data;
             QDataStream stream(&data, QIODevice::WriteOnly);
-            switch(i) {
+            switch (i) {
             case 0:
                 stream << QString("printqstring") << (int)1;
                 m_settings->m_typeMacros.insert(QLatin1String("QString"), data);
@@ -154,7 +154,7 @@ void TypeMacroPage::finished(bool accepted)
     m_settings->m_typeMacros.clear();
     m_settings->m_scriptFile = m_ui.scriptEdit->text();
 
-    for (int i=0; i<m_ui.treeWidget->topLevelItemCount(); ++i) {
+    for (int i = 0; i < m_ui.treeWidget->topLevelItemCount(); ++i) {
         QTreeWidgetItem *item = m_ui.treeWidget->topLevelItem(i);
         QByteArray data;
         QDataStream stream(&data, QIODevice::WriteOnly);
diff --git a/src/plugins/debugger/idebuggerengine.h b/src/plugins/debugger/idebuggerengine.h
index 22ed3ca184583aedf5c729c806d969d8000f5444..8c7f2d2b2e8e585bdacde4564661ff602da6aad5 100644
--- a/src/plugins/debugger/idebuggerengine.h
+++ b/src/plugins/debugger/idebuggerengine.h
@@ -36,6 +36,11 @@
 
 #include <QtCore/QObject>
 
+QT_BEGIN_NAMESPACE
+class QPoint;
+class QString;
+QT_END_NAMESPACE
+
 namespace Debugger {
 namespace Internal {
 
diff --git a/src/plugins/debugger/mode.cpp b/src/plugins/debugger/mode.cpp
index 2229cbfe6f5c06bf13e39a45eb0e293db1b0e541..234f09c207931573e8bf8beec889944b410a00bb 100644
--- a/src/plugins/debugger/mode.cpp
+++ b/src/plugins/debugger/mode.cpp
@@ -33,7 +33,6 @@
 
 #include "mode.h"
 
-#include "assert.h"
 #include "debuggerconstants.h"
 #include "debuggermanager.h"
 
@@ -48,10 +47,14 @@
 #include <coreplugin/outputpane.h>
 #include <coreplugin/navigationwidget.h>
 #include <coreplugin/rightpane.h>
+
 #include <projectexplorer/projectexplorerconstants.h>
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/QDebug>
 #include <QtCore/QSettings>
+
 #include <QtGui/QDockWidget>
 #include <QtGui/QLabel>
 #include <QtGui/QMainWindow>
@@ -213,8 +216,8 @@ void DebugMode::focusCurrentEditor(IMode *mode)
 void DebugMode::writeSettings() const
 {
     QSettings *s = settings();
-    QWB_ASSERT(m_manager, return);
-    QWB_ASSERT(m_manager->mainWindow(), return);
+    QTC_ASSERT(m_manager, return);
+    QTC_ASSERT(m_manager->mainWindow(), return);
     s->beginGroup(QLatin1String("DebugMode"));
     s->setValue(QLatin1String("State"), m_manager->mainWindow()->saveState());
     s->setValue(QLatin1String("Locked"), m_toggleLockedAction->isChecked());
diff --git a/src/plugins/debugger/scriptengine.cpp b/src/plugins/debugger/scriptengine.cpp
index 28722b37dd2a609e22d8919097707f853bffbded..e6387bfdda9a4fa7d09e2d4ab631777cf7f672f1 100644
--- a/src/plugins/debugger/scriptengine.cpp
+++ b/src/plugins/debugger/scriptengine.cpp
@@ -33,19 +33,18 @@
 
 #include "scriptengine.h"
 
-#include "assert.h"
+#include "attachexternaldialog.h"
+#include "breakhandler.h"
 #include "debuggerconstants.h"
 #include "debuggermanager.h"
-
 #include "disassemblerhandler.h"
-#include "breakhandler.h"
 #include "moduleshandler.h"
 #include "registerhandler.h"
 #include "stackhandler.h"
+#include "startexternaldialog.h"
 #include "watchhandler.h"
 
-#include "startexternaldialog.h"
-#include "attachexternaldialog.h"
+#include <utils/qtcassert.h>
 
 #include <QtCore/QDateTime>
 #include <QtCore/QDebug>
@@ -574,7 +573,7 @@ void ScriptEngine::updateSubItem(const WatchData &data0)
 {
     WatchData data = data0;
     //qDebug() << "\nUPDATE SUBITEM: " << data.toString();
-    QWB_ASSERT(data.isValid(), return);
+    QTC_ASSERT(data.isValid(), return);
 
     if (data.isTypeNeeded() || data.isValueNeeded()) {
         QScriptValue ob = data.scriptValue;
@@ -667,7 +666,7 @@ void ScriptEngine::updateSubItem(const WatchData &data0)
         return;
     }
 
-    QWB_ASSERT(false, return);
+    QTC_ASSERT(false, return);
 }
 
 IDebuggerEngine *createScriptEngine(DebuggerManager *parent)
diff --git a/src/plugins/debugger/stackhandler.cpp b/src/plugins/debugger/stackhandler.cpp
index d2a468b07c6e3bedeb83db8a1adc07d047f7c36f..fd70e1e1ab9c8f785690b0cfcdd6c28da4cc6595 100644
--- a/src/plugins/debugger/stackhandler.cpp
+++ b/src/plugins/debugger/stackhandler.cpp
@@ -33,7 +33,7 @@
 
 #include "stackhandler.h"
 
-#include "assert.h"
+#include <utils/qtcassert.h>
 
 #include <QtCore/QAbstractTableModel>
 #include <QtCore/QDebug>
@@ -128,8 +128,8 @@ Qt::ItemFlags StackHandler::flags(const QModelIndex &index) const
 
 StackFrame StackHandler::currentFrame() const
 {       
-    QWB_ASSERT(m_currentIndex >= 0, return StackFrame());
-    QWB_ASSERT(m_currentIndex < m_stackFrames.size(), return StackFrame());
+    QTC_ASSERT(m_currentIndex >= 0, return StackFrame());
+    QTC_ASSERT(m_currentIndex < m_stackFrames.size(), return StackFrame());
     return m_stackFrames.at(m_currentIndex);
 }
 
diff --git a/src/plugins/debugger/startexternaldialog.cpp b/src/plugins/debugger/startexternaldialog.cpp
index 785757b7667f42bc5ffb8fef92c6e47fe12cbdb4..cca92ff3a3f531ebc7e04fed4ec353574a5c2772 100644
--- a/src/plugins/debugger/startexternaldialog.cpp
+++ b/src/plugins/debugger/startexternaldialog.cpp
@@ -88,7 +88,7 @@ QString StartExternalDialog::executableArguments() const
         result << QLatin1String("--args");
     result << execEdit->text();
 
-    for(int i=0; i<args.length(); ++i) {
+    for (int i = 0; i < args.length(); ++i) {
         current = args.at(i);
 
         if (current == QLatin1Char('\"') && last != QLatin1Char('\\')) {
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp
index 1041c2edcc697a246d403879ca0c96575c6c50ad..053fcadcd199ea8915dc09342b8b9d4462239ec7 100644
--- a/src/plugins/debugger/watchhandler.cpp
+++ b/src/plugins/debugger/watchhandler.cpp
@@ -37,7 +37,7 @@
 #include "modeltest.h"
 #endif
 
-#include "assert.h"
+#include <utils/qtcassert.h>
 
 #include <QtCore/QDebug>
 #include <QtCore/QEvent>
@@ -118,7 +118,7 @@ static QByteArray quoteUnprintable(const QByteArray &ba)
     QByteArray res;
     char buf[10];
     for (int i = 0, n = ba.size(); i != n; ++i) {
-        char c = ba.at(i);
+        unsigned char c = ba.at(i);
         if (isprint(c)) {
             res += c;
         } else {
@@ -426,7 +426,7 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const
     int node = idx.internalId();
     if (node < 0)
         return QVariant();
-    QWB_ASSERT(node < m_displaySet.size(), return QVariant());
+    QTC_ASSERT(node < m_displaySet.size(), return QVariant());
 
     const WatchData &data = m_displaySet.at(node);
 
@@ -702,10 +702,10 @@ void WatchHandler::rebuildModel()
 
     // Possibly append dummy items to prevent empty views
     bool ok = true;
-    QWB_ASSERT(m_displaySet.size() >= 2, ok = false);
-    QWB_ASSERT(m_displaySet.at(1).iname == "local", ok = false);
-    QWB_ASSERT(m_displaySet.at(2).iname == "tooltip", ok = false);
-    QWB_ASSERT(m_displaySet.at(3).iname == "watch", ok = false);
+    QTC_ASSERT(m_displaySet.size() >= 2, ok = false);
+    QTC_ASSERT(m_displaySet.at(1).iname == "local", ok = false);
+    QTC_ASSERT(m_displaySet.at(2).iname == "tooltip", ok = false);
+    QTC_ASSERT(m_displaySet.at(3).iname == "watch", ok = false);
     if (ok) {
         for (int i = 1; i <= 3; ++i) {
             WatchData &data = m_displaySet[i];
@@ -777,7 +777,7 @@ void WatchHandler::collapseChildren(const QModelIndex &idx)
         qDebug() << "WATCHHANDLER: COLLAPSE IGNORED" << idx;
         return;
     }
-    QWB_ASSERT(checkIndex(idx.internalId()), return);
+    QTC_ASSERT(checkIndex(idx.internalId()), return);
 #if 0
     QString iname0 = m_displaySet.at(idx.internalId()).iname;
     MODEL_DEBUG("COLLAPSE NODE" << iname0);
@@ -806,11 +806,11 @@ void WatchHandler::expandChildren(const QModelIndex &idx)
     int index = idx.internalId();
     if (index == 0)
         return;
-    QWB_ASSERT(index >= 0, qDebug() << toString() << index; return);
-    QWB_ASSERT(index < m_completeSet.size(), qDebug() << toString() << index; return);
+    QTC_ASSERT(index >= 0, qDebug() << toString() << index; return);
+    QTC_ASSERT(index < m_completeSet.size(), qDebug() << toString() << index; return);
     const WatchData &display = m_displaySet.at(index);
-    QWB_ASSERT(index >= 0, qDebug() << toString() << index; return);
-    QWB_ASSERT(index < m_completeSet.size(), qDebug() << toString() << index; return);
+    QTC_ASSERT(index >= 0, qDebug() << toString() << index; return);
+    QTC_ASSERT(index < m_completeSet.size(), qDebug() << toString() << index; return);
     const WatchData &complete = m_completeSet.at(index);
     MODEL_DEBUG("\n\nEXPAND" << display.iname);
     if (display.iname.isEmpty()) {
@@ -848,7 +848,7 @@ void WatchHandler::expandChildren(const QModelIndex &idx)
 void WatchHandler::insertData(const WatchData &data)
 {
     //MODEL_DEBUG("INSERTDATA: " << data.toString());
-    QWB_ASSERT(data.isValid(), return);
+    QTC_ASSERT(data.isValid(), return);
     if (data.isSomethingNeeded())
         insertDataHelper(m_incompleteSet, data);
     else
@@ -977,7 +977,7 @@ bool WatchHandler::canFetchMore(const QModelIndex &parent) const
     // needs to be made synchronous to be useful. Busy loop is no good.
     if (!parent.isValid())
         return false;
-    QWB_ASSERT(checkIndex(parent.internalId()), return false);
+    QTC_ASSERT(checkIndex(parent.internalId()), return false);
     const WatchData &data = m_displaySet.at(parent.internalId());
     MODEL_DEBUG("CAN FETCH MORE: " << parent << " children: " << data.childCount
         << data.iname);
@@ -990,7 +990,7 @@ void WatchHandler::fetchMore(const QModelIndex &parent)
     MODEL_DEBUG("FETCH MORE: " << parent);
     return;
 
-    QWB_ASSERT(checkIndex(parent.internalId()), return);
+    QTC_ASSERT(checkIndex(parent.internalId()), return);
     QString iname = m_displaySet.at(parent.internalId()).iname;
 
     if (m_inFetchMore) {
@@ -1049,15 +1049,15 @@ QModelIndex WatchHandler::index(int row, int col, const QModelIndex &parent) con
         MODEL_DEBUG(" -> " << QModelIndex() << " (2) ");
         return QModelIndex(); 
     }
-    QWB_ASSERT(checkIndex(parentIndex), return QModelIndex());
+    QTC_ASSERT(checkIndex(parentIndex), return QModelIndex());
     const WatchData &data = m_displaySet.at(parentIndex);
-    QWB_ASSERT(row >= 0, qDebug() << "ROW: " << row  << "PARENT: " << parent
+    QTC_ASSERT(row >= 0, qDebug() << "ROW: " << row  << "PARENT: " << parent
         << data.toString() << toString(); return QModelIndex());
-    QWB_ASSERT(row < data.childIndex.size(),
+    QTC_ASSERT(row < data.childIndex.size(),
         MODEL_DEBUG("ROW: " << row << data.toString() << toString());
         return QModelIndex());
     QModelIndex idx = createIndex(row, col, data.childIndex.at(row));
-    QWB_ASSERT(idx.row() == m_displaySet.at(idx.internalId()).row,
+    QTC_ASSERT(idx.row() == m_displaySet.at(idx.internalId()).row,
         return QModelIndex());
     MODEL_DEBUG(" -> " << idx << " (A) ");
     return idx;
@@ -1071,15 +1071,15 @@ QModelIndex WatchHandler::parent(const QModelIndex &idx) const
     }
     MODEL_DEBUG("PARENT " << idx);
     int currentIndex = idx.internalId();
-    QWB_ASSERT(checkIndex(currentIndex), return QModelIndex());
-    QWB_ASSERT(idx.row() == m_displaySet.at(currentIndex).row,
+    QTC_ASSERT(checkIndex(currentIndex), return QModelIndex());
+    QTC_ASSERT(idx.row() == m_displaySet.at(currentIndex).row,
         MODEL_DEBUG("IDX: " << idx << toString(); return QModelIndex()));
     int parentIndex = m_displaySet.at(currentIndex).parentIndex;
     if (parentIndex < 0) {
         MODEL_DEBUG(" -> " << QModelIndex() << " (2) ");
         return QModelIndex();
     }
-    QWB_ASSERT(checkIndex(parentIndex), return QModelIndex());
+    QTC_ASSERT(checkIndex(parentIndex), return QModelIndex());
     QModelIndex parent = 
         createIndex(m_displaySet.at(parentIndex).row, 0, parentIndex);
     MODEL_DEBUG(" -> " << parent);
@@ -1094,7 +1094,7 @@ int WatchHandler::rowCount(const QModelIndex &idx) const
         return 0;
     }
     int thisIndex = idx.internalId();
-    QWB_ASSERT(checkIndex(thisIndex), return 0);
+    QTC_ASSERT(checkIndex(thisIndex), return 0);
     if (idx.row() == -1 && idx.column() == -1) {
         MODEL_DEBUG(" -> " << 3 << " (B) ");
         return 1;
@@ -1129,7 +1129,7 @@ int WatchHandler::columnCount(const QModelIndex &idx) const
         return 0;
     }
     MODEL_DEBUG(" -> " << 3 << " (B) ");
-    QWB_ASSERT(checkIndex(idx.internalId()), return 3);
+    QTC_ASSERT(checkIndex(idx.internalId()), return 3);
     return 3;
 }
 
@@ -1139,7 +1139,7 @@ bool WatchHandler::hasChildren(const QModelIndex &idx) const
     bool base = rowCount(idx) > 0 && columnCount(idx) > 0;
     MODEL_DEBUG("HAS CHILDREN: " << idx << base);
     return base;
-    QWB_ASSERT(checkIndex(idx.internalId()), return false);
+    QTC_ASSERT(checkIndex(idx.internalId()), return false);
     const WatchData &data = m_displaySet.at(idx.internalId());
     MODEL_DEBUG("HAS CHILDREN: " << idx << data.toString());
     return data.childCount > 0; // || data.childIndex.size() > 0;
diff --git a/src/plugins/designer/cpp/formclasswizardparameters.cpp b/src/plugins/designer/cpp/formclasswizardparameters.cpp
index 7dd0056186a2dfc9440dfc835671b69970dbb2c5..10dda881db93fe54c1978f92506de35254776eba 100644
--- a/src/plugins/designer/cpp/formclasswizardparameters.cpp
+++ b/src/plugins/designer/cpp/formclasswizardparameters.cpp
@@ -156,7 +156,7 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
     if (languageChange) {
         sourceStr  << '\n' << namespaceIndent << "void " << unqualifiedClassName << "::" << "changeEvent(QEvent *e)\n"
         << namespaceIndent << "{\n"
-        << namespaceIndent << indent << "switch(e->type()) {\n" << namespaceIndent << indent << "case QEvent::LanguageChange:\n"
+        << namespaceIndent << indent << "switch (e->type()) {\n" << namespaceIndent << indent << "case QEvent::LanguageChange:\n"
         << namespaceIndent << indent << indent;
         if (embedding != InheritedUiClass)
             sourceStr << uiMemberC << (embedding == PointerAggregatedUiClass ? "->" : ".");
diff --git a/src/plugins/designer/editorwidget.cpp b/src/plugins/designer/editorwidget.cpp
index 1a60dbb171540e33b7c1c7f64a9057cc8efb2b73..794db9e0cb703e2724cdce5db1b7027f0fde1b59 100644
--- a/src/plugins/designer/editorwidget.cpp
+++ b/src/plugins/designer/editorwidget.cpp
@@ -35,6 +35,7 @@
 #include "formeditorw.h"
 
 #include <coreplugin/minisplitter.h>
+#include <utils/qtcassert.h>
 
 #include <QtCore/QEvent>
 #include <QtGui/QVBoxLayout>
@@ -54,7 +55,7 @@ SharedSubWindow::SharedSubWindow(QWidget *shared, QWidget *parent) :
    m_shared(shared),
    m_layout(new QVBoxLayout)
 {
-    Q_ASSERT(m_shared);
+    QTC_ASSERT(m_shared, /**/);
     m_layout->setContentsMargins(0, 0, 0, 0);
     setLayout(m_layout);
 }
@@ -62,14 +63,14 @@ SharedSubWindow::SharedSubWindow(QWidget *shared, QWidget *parent) :
 void SharedSubWindow::activate()
 {
     // Take the widget off the other parent
-    Q_ASSERT(m_shared);
+    QTC_ASSERT(m_shared, return);
     QWidget *currentParent = m_shared->parentWidget();
     if (currentParent == this)
         return;
 
     if (currentParent) {
         QVBoxLayout *lt = qobject_cast<QVBoxLayout *>(currentParent->layout());
-        Q_ASSERT(lt);
+        QTC_ASSERT(lt, return);
         m_shared->setParent(0);
         delete lt->takeAt(0);
     }
diff --git a/src/plugins/designer/formeditorw.cpp b/src/plugins/designer/formeditorw.cpp
index c156dec1b7f5416cf3a94cde812613e0f08465a4..01f159f991eff3f47822afef5593953087e7d00a 100644
--- a/src/plugins/designer/formeditorw.cpp
+++ b/src/plugins/designer/formeditorw.cpp
@@ -43,6 +43,7 @@
 #include <coreplugin/uniqueidmanager.h>
 #include <coreplugin/actionmanager/actionmanagerinterface.h>
 #include <coreplugin/editormanager/editormanager.h>
+#include <utils/qtcassert.h>
 
 #include <QtDesigner/QDesignerFormEditorPluginInterface>
 #include <QtDesigner/private/pluginmanager_p.h>
@@ -169,9 +170,9 @@ FormEditorW::FormEditorW() :
 {
     if (debugFormEditor)
         qDebug() << Q_FUNC_INFO;
-    Q_ASSERT(!m_self);
+    QTC_ASSERT(!m_self, return);
     m_self = this;
-    Q_ASSERT(m_core);
+    QTC_ASSERT(m_core, return);
 
     qFill(m_designerSubWindows, m_designerSubWindows + Designer::Constants::DesignerSubWindowCount,
           static_cast<QWidget *>(0));
@@ -180,7 +181,7 @@ FormEditorW::FormEditorW() :
     m_formeditor->setSettingsManager(new SettingsManager());
 
     m_fwm = qobject_cast<qdesigner_internal::QDesignerFormWindowManager*>(m_formeditor->formWindowManager());
-    Q_ASSERT(m_fwm);
+    QTC_ASSERT(m_fwm, return);
 
     const int uid = m_core->uniqueIDManager()->uniqueIdentifier(QLatin1String(C_FORMEDITOR));
     m_context << uid;
@@ -216,7 +217,7 @@ FormEditorW::~FormEditorW()
 
 void FormEditorW::fullInit()
 {
-    Q_ASSERT(m_initStage == RegisterPlugins);
+    QTC_ASSERT(m_initStage == RegisterPlugins, return);
     QTime *initTime = 0;
     if (debugFormEditor) {
         initTime = new QTime;
@@ -410,7 +411,7 @@ void FormEditorW::setupActions()
     createSeparator(this, am, m_context, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator2"));
 
     m_actionPreview = m_fwm->actionDefaultPreview();
-    Q_ASSERT(m_actionPreview);
+    QTC_ASSERT(m_actionPreview, return);
     addToolAction(m_actionPreview,  am,  m_context,
                    QLatin1String("FormEditor.Preview"), mformtools, tr("Ctrl+Alt+R"));
 
@@ -445,8 +446,8 @@ QToolBar *FormEditorW::createEditorToolBar() const
     Core::ActionManagerInterface *am = m_core->actionManager();
     const QStringList::const_iterator cend = m_toolActionIds.constEnd();
     for (QStringList::const_iterator it = m_toolActionIds.constBegin(); it != cend; ++it) {
-        Core::ICommand *cmd =  am->command(*it);
-        Q_ASSERT(cmd);
+        Core::ICommand *cmd = am->command(*it);
+        QTC_ASSERT(cmd, continue);
         QAction *action = cmd->action();
         if (!action->icon().isNull()) // Simplify grid has no action yet
             rc->addAction(action);
@@ -472,7 +473,7 @@ Core::IActionContainer *FormEditorW::createPreviewStyleMenu(Core::ActionManagerI
     const QString deviceProfilePrefix = QLatin1String("DeviceProfile");
     const QChar dot = QLatin1Char('.');
 
-    foreach(QAction* a, actions) {
+    foreach (QAction* a, actions) {
         QString name = menuId;
         name += dot;
         const QVariant data = a->data();
@@ -591,7 +592,7 @@ void FormEditorW::currentEditorChanged(Core::IEditor *editor)
     // Deactivate Designer if a non-form is being edited
     if (editor && !qstrcmp(editor->kind(), Constants::C_FORMWINDOW)) {
         FormWindowEditor *fw = qobject_cast<FormWindowEditor *>(editor);
-        Q_ASSERT(fw);
+        QTC_ASSERT(fw, return);
         fw->activate();
         m_fwm->setActiveFormWindow(fw->formWindow());
     } else {
diff --git a/src/plugins/find/basetextfind.cpp b/src/plugins/find/basetextfind.cpp
index 6598a47e6f3085409ba899c3f13f4903dd3ffe55..d6a2e9997e87600a7620aa2aca59fae7f3dfa5e6 100644
--- a/src/plugins/find/basetextfind.cpp
+++ b/src/plugins/find/basetextfind.cpp
@@ -33,6 +33,8 @@
 
 #include "basetextfind.h"
 
+#include <utils/qtcassert.h>
+
 #include <QtGui/QTextBlock>
 
 using namespace Find;
@@ -49,26 +51,26 @@ BaseTextFind::BaseTextFind(QPlainTextEdit *editor)
 
 QTextCursor BaseTextFind::textCursor() const
 {
-    Q_ASSERT(m_editor || m_plaineditor);
+    QTC_ASSERT(m_editor || m_plaineditor, return QTextCursor());
     return m_editor ? m_editor->textCursor() : m_plaineditor->textCursor();
 
 }
 
 void BaseTextFind::setTextCursor(const QTextCursor& cursor)
 {
-    Q_ASSERT(m_editor || m_plaineditor);
+    QTC_ASSERT(m_editor || m_plaineditor, return);
     m_editor ? m_editor->setTextCursor(cursor) : m_plaineditor->setTextCursor(cursor);
 }
 
 QTextDocument *BaseTextFind::document() const
 {
-    Q_ASSERT(m_editor || m_plaineditor);
+    QTC_ASSERT(m_editor || m_plaineditor, return 0);
     return m_editor ? m_editor->document() : m_plaineditor->document();
 }
 
 bool BaseTextFind::isReadOnly() const
 {
-    Q_ASSERT(m_editor || m_plaineditor);
+    QTC_ASSERT(m_editor || m_plaineditor, return true);
     return m_editor ? m_editor->isReadOnly() : m_plaineditor->isReadOnly();
 }
 
@@ -101,7 +103,7 @@ QString BaseTextFind::currentFindString() const
         cursor.movePosition(QTextCursor::StartOfWord);
         cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
         QString s = cursor.selectedText();
-        foreach(QChar c, s) {
+        foreach (QChar c, s) {
             if (!c.isLetterOrNumber() && c != QLatin1Char('_')) {
                 s.clear();
                 break;
diff --git a/src/plugins/find/currentdocumentfind.cpp b/src/plugins/find/currentdocumentfind.cpp
index 091c307d3d0a7af46cba3ec14e150e35e767c435..59d05919cf8d0fc2ee17cab29b4866c8ec8a7137 100644
--- a/src/plugins/find/currentdocumentfind.cpp
+++ b/src/plugins/find/currentdocumentfind.cpp
@@ -36,16 +36,17 @@
 #include <aggregation/aggregate.h>
 #include <coreplugin/coreconstants.h>
 #include <coreplugin/modemanager.h>
+#include <utils/qtcassert.h>
 
+#include <QtCore/QDebug>
 #include <QtGui/QApplication>
-#include <QtDebug>
 
 using namespace Core;
 using namespace Find;
 using namespace Find::Internal;
 
 CurrentDocumentFind::CurrentDocumentFind(ICore *core)
-        : m_core(core), m_currentFind(0)
+  : m_core(core), m_currentFind(0)
 {
     connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)),
             this, SLOT(updateCurrentFindFilter(QWidget*,QWidget*)));
@@ -59,16 +60,14 @@ void CurrentDocumentFind::removeConnections()
 
 void CurrentDocumentFind::resetIncrementalSearch()
 {
-    Q_ASSERT(m_currentFind);
-    if (m_currentFind)
-        m_currentFind->resetIncrementalSearch();
+    QTC_ASSERT(m_currentFind, return);
+    m_currentFind->resetIncrementalSearch();
 }
 
 void CurrentDocumentFind::clearResults()
 {
-    Q_ASSERT(m_currentFind);
-    if (m_currentFind)
-        m_currentFind->clearResults();
+    QTC_ASSERT(m_currentFind, return);
+    m_currentFind->clearResults();
 }
 
 bool CurrentDocumentFind::isEnabled() const
@@ -78,67 +77,64 @@ bool CurrentDocumentFind::isEnabled() const
 
 bool CurrentDocumentFind::supportsReplace() const
 {
-    Q_ASSERT(m_currentFind);
-    return m_currentFind ? m_currentFind->supportsReplace() : false;
+    QTC_ASSERT(m_currentFind, return false);
+    return m_currentFind->supportsReplace();
 }
 
 QString CurrentDocumentFind::currentFindString() const
 {
-    Q_ASSERT(m_currentFind);
-    return m_currentFind ? m_currentFind->currentFindString() : QString();
+    QTC_ASSERT(m_currentFind, return QString());
+    return m_currentFind->currentFindString();
 }
 
 QString CurrentDocumentFind::completedFindString() const
 {
-    Q_ASSERT(m_currentFind);
-    return m_currentFind ? m_currentFind->completedFindString() : QString();
+    QTC_ASSERT(m_currentFind, return QString());
+    return m_currentFind->completedFindString();
 }
 
 void CurrentDocumentFind::highlightAll(const QString &txt, QTextDocument::FindFlags findFlags)
 {
-    Q_ASSERT(m_currentFind);
-    if (m_currentFind)
-        m_currentFind->highlightAll(txt, findFlags);
+    QTC_ASSERT(m_currentFind, return);
+    m_currentFind->highlightAll(txt, findFlags);
 }
 
 bool CurrentDocumentFind::findIncremental(const QString &txt, QTextDocument::FindFlags findFlags)
 {
-    Q_ASSERT(m_currentFind);
-    return (m_currentFind? m_currentFind->findIncremental(txt, findFlags) : false);
+    QTC_ASSERT(m_currentFind, return false);
+    return m_currentFind->findIncremental(txt, findFlags);
 }
 
 bool CurrentDocumentFind::findStep(const QString &txt, QTextDocument::FindFlags findFlags)
 {
-    Q_ASSERT(m_currentFind);
-    return (m_currentFind? m_currentFind->findStep(txt, findFlags) : false);
+    QTC_ASSERT(m_currentFind, return false);
+    return m_currentFind->findStep(txt, findFlags);
 }
 
 bool CurrentDocumentFind::replaceStep(const QString &before, const QString &after,
     QTextDocument::FindFlags findFlags)
 {
-    Q_ASSERT(m_currentFind);
-    return (m_currentFind? m_currentFind->replaceStep(before, after, findFlags) : false);
+    QTC_ASSERT(m_currentFind, return false);
+    return m_currentFind->replaceStep(before, after, findFlags);
 }
 
 int CurrentDocumentFind::replaceAll(const QString &before, const QString &after,
     QTextDocument::FindFlags findFlags)
 {
-    Q_ASSERT(m_currentFind);
-    return (m_currentFind? m_currentFind->replaceAll(before, after, findFlags) : 0);
+    QTC_ASSERT(m_currentFind, return 0);
+    return m_currentFind->replaceAll(before, after, findFlags);
 }
 
 void CurrentDocumentFind::defineFindScope()
 {
-    Q_ASSERT(m_currentFind);
-    if (m_currentFind)
-        m_currentFind->defineFindScope();
+    QTC_ASSERT(m_currentFind, return);
+    m_currentFind->defineFindScope();
 }
 
 void CurrentDocumentFind::clearFindScope()
 {
-    Q_ASSERT(m_currentFind);
-    if (m_currentFind)
-        m_currentFind->clearFindScope();
+    QTC_ASSERT(m_currentFind, return);
+    m_currentFind->clearFindScope();
 }
 
 void CurrentDocumentFind::updateCurrentFindFilter(QWidget *old, QWidget *now)
diff --git a/src/plugins/find/findplugin.cpp b/src/plugins/find/findplugin.cpp
index 344ee578e5b03d74c9aad398885ef9e3416a8812..766c435a50355faf3feccc9fa05ed287cf94b0b9 100644
--- a/src/plugins/find/findplugin.cpp
+++ b/src/plugins/find/findplugin.cpp
@@ -30,6 +30,7 @@
 ** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
 **
 ***************************************************************************/
+
 #include "findplugin.h"
 
 #include "textfindconstants.h"
@@ -42,6 +43,8 @@
 #include <coreplugin/actionmanager/icommand.h>
 #include <coreplugin/coreconstants.h>
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/qplugin.h>
 #include <QtCore/QSettings>
 
@@ -102,24 +105,18 @@ void FindPlugin::filterChanged()
 {
     IFindFilter *changedFilter = qobject_cast<IFindFilter *>(sender());
     QAction *action = m_filterActions.value(changedFilter);
-    Q_ASSERT(changedFilter);
-    Q_ASSERT(action);
-    if (!changedFilter || !action)
-        return;
+    QTC_ASSERT(changedFilter, return);
+    QTC_ASSERT(action, return);
     action->setEnabled(changedFilter->isEnabled());
 }
 
 void FindPlugin::openFindFilter()
 {
     QAction *action = qobject_cast<QAction*>(sender());
-    Q_ASSERT(action);
-    if (!action)
-        return;
+    QTC_ASSERT(action, return);
     IFindFilter *filter = action->data().value<IFindFilter *>();
-    Q_ASSERT(filter);
-    Q_ASSERT(filter->isEnabled());
-    if (!filter || !filter->isEnabled())
-        return;
+    QTC_ASSERT(filter, return);
+    QTC_ASSERT(filter->isEnabled(), return);
     QString currentFindString = (m_currentDocumentFind->isEnabled() ? m_currentDocumentFind->currentFindString() : "");
     if (!currentFindString.isEmpty())
         m_findDialog->setFindText(currentFindString);
diff --git a/src/plugins/find/findwidget.ui b/src/plugins/find/findwidget.ui
index c85f33629970dc20682ad6155d02ae012028caeb..f4b0c82ed2594414284ba031070350bcb8f9a49d 100644
--- a/src/plugins/find/findwidget.ui
+++ b/src/plugins/find/findwidget.ui
@@ -56,6 +56,9 @@
      </item>
      <item>
       <widget class="QToolButton" name="findPreviousButton">
+       <property name="focusPolicy">
+        <enum>Qt::NoFocus</enum>
+       </property>
        <property name="arrowType">
         <enum>Qt::LeftArrow</enum>
        </property>
@@ -66,6 +69,9 @@
        <property name="font">
         <font/>
        </property>
+       <property name="focusPolicy">
+        <enum>Qt::NoFocus</enum>
+       </property>
        <property name="arrowType">
         <enum>Qt::RightArrow</enum>
        </property>
@@ -103,6 +109,9 @@
      </item>
      <item>
       <widget class="QToolButton" name="replacePreviousButton">
+       <property name="focusPolicy">
+        <enum>Qt::NoFocus</enum>
+       </property>
        <property name="arrowType">
         <enum>Qt::LeftArrow</enum>
        </property>
@@ -113,6 +122,9 @@
        <property name="font">
         <font/>
        </property>
+       <property name="focusPolicy">
+        <enum>Qt::NoFocus</enum>
+       </property>
        <property name="arrowType">
         <enum>Qt::RightArrow</enum>
        </property>
diff --git a/src/plugins/git/changeselectiondialog.cpp b/src/plugins/git/changeselectiondialog.cpp
index 70004dbadfa7bb5e39320eb99ca5b0646d84b447..46eab385ac817c0273268e08d809cfcb8ff15b32 100644
--- a/src/plugins/git/changeselectiondialog.cpp
+++ b/src/plugins/git/changeselectiondialog.cpp
@@ -43,6 +43,7 @@ ChangeSelectionDialog::ChangeSelectionDialog(QWidget *parent)
 {
     m_ui.setupUi(this);
     connect(m_ui.repositoryButton, SIGNAL(clicked()), this, SLOT(selectWorkingDirectory()));
+    setWindowTitle(tr("Select a Git commit"));
 }
 
 void ChangeSelectionDialog::selectWorkingDirectory()
@@ -59,7 +60,7 @@ void ChangeSelectionDialog::selectWorkingDirectory()
     // the head directory of the repository.
     QDir repository(location);
     do {
-        if (repository.entryList(QDir::AllDirs).contains(QLatin1String(".git"))) {
+        if (repository.entryList(QDir::AllDirs|QDir::Hidden).contains(QLatin1String(".git"))) {
             m_ui.repositoryEdit->setText(repository.absolutePath());
             return;
         }
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index a1668e60cebcf93343e54862c30a7f429cf933dd..ff0cdbde5e40ca31e081f0f0bb58aae6e39d5eca 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -32,36 +32,38 @@
 ***************************************************************************/
 
 #include "gitclient.h"
-#include "gitplugin.h"
-#include "gitconstants.h"
+
 #include "commitdata.h"
+#include "gitconstants.h"
+#include "gitplugin.h"
 #include "gitsubmiteditor.h"
 
-#include <coreplugin/icore.h>
-#include <coreplugin/coreconstants.h>
-#include <coreplugin/messagemanager.h>
-#include <coreplugin/uniqueidmanager.h>
 #include <coreplugin/actionmanager/actionmanagerinterface.h>
+#include <coreplugin/coreconstants.h>
 #include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/icore.h>
+#include <coreplugin/messagemanager.h>
 #include <coreplugin/progressmanager/progressmanagerinterface.h>
-#include <vcsbase/vcsbaseeditor.h>
+#include <coreplugin/uniqueidmanager.h>
 #include <texteditor/itexteditor.h>
+#include <utils/qtcassert.h>
+#include <vcsbase/vcsbaseeditor.h>
 
+#include <QtCore/QFuture>
 #include <QtCore/QRegExp>
 #include <QtCore/QTemporaryFile>
-#include <QtCore/QFuture>
 #include <QtCore/QTime>
 
-#include <QtGui/QMessageBox>
 #include <QtGui/QMainWindow> // for msg box parent
+#include <QtGui/QMessageBox>
 #include <QtGui/QPushButton>
 
 using namespace Git;
 using namespace Git::Internal;
 
-const char* const kGitCommand = "git";
-const char* const kGitDirectoryC = ".git";
-const char* const kBranchIndicatorC = "# On branch";
+const char *const kGitCommand = "git";
+const char *const kGitDirectoryC = ".git";
+const char *const kBranchIndicatorC = "# On branch";
 
 enum { untrackedFilesInCommit = 0 };
 
@@ -169,14 +171,14 @@ VCSBase::VCSBaseEditor
          // Exists already
         outputEditor->createNew(m_msgWait);
         rc = VCSBase::VCSBaseEditor::getVcsBaseEditor(outputEditor);
-        Q_ASSERT(rc);
+        QTC_ASSERT(rc, return 0);
         m_core->editorManager()->setCurrentEditor(outputEditor);
     } else {
         // Create new, set wait message, set up with source and codec
         outputEditor = m_core->editorManager()->newFile(kind, &title, m_msgWait);
         outputEditor->setProperty(registerDynamicProperty, dynamicPropertyValue);
         rc = VCSBase::VCSBaseEditor::getVcsBaseEditor(outputEditor);
-        Q_ASSERT(rc);
+        QTC_ASSERT(rc, return 0);
         rc->setSource(source);
         if (setSourceCodec)
             rc->setCodec(VCSBase::VCSBaseEditor::getCodec(m_core, source));
@@ -394,11 +396,10 @@ void GitClient::executeGit(const QString &workingDirectory, const QStringList &a
 
     GitCommand* command = new GitCommand();
     if (outputToWindow) {
-        Q_ASSERT(outputWindow);
         connect(command, SIGNAL(outputText(QString)), outputWindow, SLOT(append(QString)));
         connect(command, SIGNAL(outputData(QByteArray)), outputWindow, SLOT(appendData(QByteArray)));
     } else {
-        Q_ASSERT(editor);
+        QTC_ASSERT(editor, /**/);
         connect(command, SIGNAL(outputText(QString)), editor, SLOT(setPlainText(QString)));
         connect(command, SIGNAL(outputData(QByteArray)), editor, SLOT(setPlainTextData(QByteArray)));
     }
@@ -515,7 +516,7 @@ static bool parseFiles(const QString &output, CommitData *d)
     State s = None;
     // Match added/changed-not-updated files: "#<tab>modified: foo.cpp"
     QRegExp filesPattern(QLatin1String("#\\t[^:]+:\\s+.+"));
-    Q_ASSERT(filesPattern.isValid());
+    QTC_ASSERT(filesPattern.isValid(), return false);
 
     const QStringList::const_iterator cend = lines.constEnd();
     for (QStringList::const_iterator it =  lines.constBegin(); it != cend; ++it) {
@@ -533,7 +534,7 @@ static bool parseFiles(const QString &output, CommitData *d)
                         // Now match untracked: "#<tab>foo.cpp"
                         s = UntrackedFiles;
                         filesPattern = QRegExp(QLatin1String("#\\t.+"));
-                        Q_ASSERT(filesPattern.isValid());
+                        QTC_ASSERT(filesPattern.isValid(), return false);
                     } else {
                         if (filesPattern.exactMatch(line)) {
                             const QString fileSpec = line.mid(2).trimmed();
diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp
index 733a6abc0d5bfb84a5b6eb2700d75487da9a66aa..a92e14eea198b3f42246e52998adb964541410d2 100644
--- a/src/plugins/git/giteditor.cpp
+++ b/src/plugins/git/giteditor.cpp
@@ -32,22 +32,25 @@
 ***************************************************************************/
 
 #include "giteditor.h"
+
 #include "annotationhighlighter.h"
+#include "gitclient.h"
 #include "gitconstants.h"
 #include "gitplugin.h"
-#include "gitclient.h"
 
-#include <vcsbase/diffhighlighter.h>
 #include <coreplugin/editormanager/editormanager.h>
+#include <utils/qtcassert.h>
+#include <vcsbase/diffhighlighter.h>
 
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
 #include <QtCore/QFileInfo>
-#include <QtCore/QTextStream>
-#include <QtCore/QSet>
 #include <QtCore/QRegExp>
-#include <QtCore/QDir>
-#include <QtCore/QDebug>
-#include <QtGui/QTextEdit>
+#include <QtCore/QSet>
+#include <QtCore/QTextStream>
+
 #include <QtGui/QTextCursor>
+#include <QtGui/QTextEdit>
 
 #define CHANGE_PATTERN_8C "[a-f0-9]{8,8}"
 #define CHANGE_PATTERN_40C "[a-f0-9]{40,40}"
@@ -62,8 +65,8 @@ GitEditor::GitEditor(const VCSBase::VCSBaseEditorParameters *type,
     m_changeNumberPattern8(QLatin1String(CHANGE_PATTERN_8C)),
     m_changeNumberPattern40(QLatin1String(CHANGE_PATTERN_40C))
 {
-    Q_ASSERT(m_changeNumberPattern8.isValid());
-    Q_ASSERT(m_changeNumberPattern40.isValid());
+    QTC_ASSERT(m_changeNumberPattern8.isValid(), return);
+    QTC_ASSERT(m_changeNumberPattern40.isValid(), return);
     if (Git::Constants::debug)
         qDebug() << "GitEditor::GitEditor" << type->type << type->kind;
 }
@@ -76,11 +79,11 @@ QSet<QString> GitEditor::annotationChanges() const
         return changes;
     // Hunt for first change number in annotation: "<change>:"
     QRegExp r(QLatin1String("^("CHANGE_PATTERN_8C") "));
-    Q_ASSERT(r.isValid());
+    QTC_ASSERT(r.isValid(), return changes);
     if (r.indexIn(txt) != -1) {
         changes.insert(r.cap(1));
         r.setPattern(QLatin1String("\n("CHANGE_PATTERN_8C") "));
-        Q_ASSERT(r.isValid());
+        QTC_ASSERT(r.isValid(), return changes);
         int pos = 0;
         while ((pos = r.indexIn(txt, pos)) != -1) {
             pos += r.matchedLength();
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index ebce0f7c452dbf9624a7186d3aded21a0fe056d0..d9187f542a9852f7e04bea63f428dcf4e108fd20 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -32,13 +32,14 @@
 ***************************************************************************/
 
 #include "gitplugin.h"
+
+#include "changeselectiondialog.h"
+#include "commitdata.h"
 #include "gitclient.h"
-#include "gitversioncontrol.h"
-#include "giteditor.h"
 #include "gitconstants.h"
-#include "changeselectiondialog.h"
+#include "giteditor.h"
 #include "gitsubmiteditor.h"
-#include "commitdata.h"
+#include "gitversioncontrol.h"
 
 #include <coreplugin/icore.h>
 #include <coreplugin/coreconstants.h>
@@ -47,20 +48,24 @@
 #include <coreplugin/uniqueidmanager.h>
 #include <coreplugin/actionmanager/actionmanagerinterface.h>
 #include <coreplugin/editormanager/editormanager.h>
+
+#include <utils/qtcassert.h>
+
 #include <vcsbase/basevcseditorfactory.h>
 #include <vcsbase/vcsbaseeditor.h>
 #include <vcsbase/basevcssubmiteditorfactory.h>
 
 #include <QtCore/qplugin.h>
 #include <QtCore/QDebug>
+#include <QtCore/QDir>
 #include <QtCore/QFileInfo>
 #include <QtCore/QTemporaryFile>
-#include <QtCore/QDir>
+
 #include <QtGui/QAction>
+#include <QtGui/QFileDialog>
+#include <QtGui/QMainWindow>
 #include <QtGui/QMenu>
 #include <QtGui/QMessageBox>
-#include <QtGui/QMainWindow>
-#include <QtGui/QFileDialog>
 
 static const VCSBase::VCSBaseEditorParameters editorParameters[] = {
 {
@@ -142,7 +147,6 @@ GitPlugin::GitPlugin() :
     m_versionControl(0),
     m_changeTmpFile(0)
 {
-    Q_ASSERT(m_instance == 0);
     m_instance = this;
 }
 
@@ -161,7 +165,7 @@ GitPlugin::~GitPlugin()
     }
 
     if (!m_editorFactories.empty()) {
-        foreach(Core::IEditorFactory* pf, m_editorFactories)
+        foreach (Core::IEditorFactory* pf, m_editorFactories)
             removeObject(pf);
         qDeleteAll(m_editorFactories);
     }
@@ -212,10 +216,10 @@ static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = {
     Git::Constants::DIFF_SELECTED
 };
 
-static inline Core::ICommand *createSeparator(Core::ActionManagerInterface *am,
-                                              const QList<int> &context,
-                                              const QString &id,
-                                              QObject *parent)
+static Core::ICommand *createSeparator(Core::ActionManagerInterface *am,
+                                       const QList<int> &context,
+                                       const QString &id,
+                                       QObject *parent)
 {
     QAction *a = new QAction(parent);
     a->setSeparator(true);
@@ -627,7 +631,7 @@ Core::IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const Commit
         qDebug() << Q_FUNC_INFO << fileName << editor;
     m_core->editorManager()->ensureEditorManagerVisible();
     GitSubmitEditor *submitEditor = qobject_cast<GitSubmitEditor*>(editor);
-    Q_ASSERT(submitEditor);
+    QTC_ASSERT(submitEditor, return 0);
     // The actions are for some reason enabled by the context switching
     // mechanism. Disable them correctly.
     m_submitCurrentAction->setEnabled(!cd.stagedFiles.empty());
diff --git a/src/plugins/help/contentstoolwindow.cpp b/src/plugins/help/contentstoolwindow.cpp
index ccd540bfef76b4041a6fa18ac4927ca70d6b51d5..3c14d7f1b8ef3202240a9d8c1008b325d86ed545 100644
--- a/src/plugins/help/contentstoolwindow.cpp
+++ b/src/plugins/help/contentstoolwindow.cpp
@@ -126,7 +126,7 @@ void ContentsToolWindow::contentsDone()
 {    
     m_widget->setCursor(QCursor(Qt::WaitCursor));
     QList<QPair<QString, ContentList> > contentList = helpEngine->contents();
-    for(QList<QPair<QString, ContentList> >::Iterator it = contentList.begin(); it != contentList.end(); ++it) {
+    for (QList<QPair<QString, ContentList> >::Iterator it = contentList.begin(); it != contentList.end(); ++it) {
         QTreeWidgetItem *newEntry;
         QTreeWidgetItem *contentEntry;
         QStack<QTreeWidgetItem*> stack;
@@ -135,7 +135,7 @@ void ContentsToolWindow::contentsDone()
         bool root = false;
 
         QTreeWidgetItem *lastItem[64];
-        for(int j = 0; j < 64; ++j)
+        for (int j = 0; j < 64; ++j)
             lastItem[j] = 0;
 
         ContentList lst = (*it).second;
@@ -149,19 +149,18 @@ void ContentsToolWindow::contentsDone()
                 stack.push(newEntry);
                 depth = 1;
                 root = true;
-            }
-            else{
-                if((item.depth > depth) && root) {
+            } else {
+                if (item.depth > depth && root) {
                     depth = item.depth;
                     stack.push(contentEntry);
                 }
-                if(item.depth == depth) {
+                if (item.depth == depth) {
                     contentEntry = new QTreeWidgetItem(stack.top(), lastItem[ depth ]);
                     lastItem[ depth ] = contentEntry;
                     contentEntry->setText(0, item.title);
                     contentEntry->setData(0, LinkRole, item.reference);
                 }
-                else if(item.depth < depth) {
+                else if (item.depth < depth) {
                     stack.pop();
                     depth--;
                     item = *(--it);
diff --git a/src/plugins/help/helpengine.cpp b/src/plugins/help/helpengine.cpp
index db259f7aa0328cbf5c2a900f8fa2df9831b5315c..44501d25abcb8bcff9065a509a16983e639e4ffa 100644
--- a/src/plugins/help/helpengine.cpp
+++ b/src/plugins/help/helpengine.cpp
@@ -296,7 +296,7 @@ quint32 HelpEngine::getFileAges()
     QStringList::const_iterator i = addDocuFiles.begin();
 
     quint32 fileAges = 0;
-    for(; i != addDocuFiles.end(); ++i) {
+    for (; i != addDocuFiles.end(); ++i) {
         QFileInfo fi(*i);
         if (fi.exists())
             fileAges += fi.lastModified().toTime_t();
@@ -364,7 +364,7 @@ void TitleMapThread::run()
     bool needRebuild = false;
     if (Config::configuration()->profileName() == QLatin1String("default")) {
         const QStringList docuFiles = Config::configuration()->docFiles();
-        for(QStringList::ConstIterator it = docuFiles.begin(); it != docuFiles.end(); it++) {
+        for (QStringList::ConstIterator it = docuFiles.begin(); it != docuFiles.end(); it++) {
             if (!QFile::exists(*it)) {
                 Config::configuration()->saveProfile(Profile::createDefaultProfile());
                 Config::configuration()->loadDefaultProfile();
@@ -383,7 +383,7 @@ void TitleMapThread::run()
         getAllContents();
     
     titleMap.clear();
-    for(QList<QPair<QString, ContentList> >::Iterator it = contentList.begin(); it != contentList.end(); ++it) {
+    for (QList<QPair<QString, ContentList> >::Iterator it = contentList.begin(); it != contentList.end(); ++it) {
         ContentList lst = (*it).second;
         foreach (ContentItem item, lst) {
             titleMap[item.reference] = item.title.trimmed();
@@ -430,7 +430,7 @@ void TitleMapThread::buildContentDict()
     QStringList docuFiles = Config::configuration()->docFiles();
 
     quint32 fileAges = 0;
-    for(QStringList::iterator it = docuFiles.begin(); it != docuFiles.end(); it++) {
+    for (QStringList::iterator it = docuFiles.begin(); it != docuFiles.end(); it++) {
         QFile file(*it);
         if (!file.exists()) {
 #ifdef _SHOW_ERRORS_
@@ -441,7 +441,7 @@ void TitleMapThread::buildContentDict()
         }
         fileAges += QFileInfo(file).lastModified().toTime_t();
         DocuParser *handler = DocuParser::createParser(*it);
-        if(!handler) {
+        if (!handler) {
 #ifdef _SHOW_ERRORS_
             emit errorOccured(tr("Documentation file %1 is not compatible!\n"
                 "Skipping file.").arg(QFileInfo(file).absoluteFilePath()));
@@ -450,7 +450,7 @@ void TitleMapThread::buildContentDict()
         }
         bool ok = handler->parse(&file);
         file.close();
-        if(ok) {
+        if (ok) {
             contentList += qMakePair(*it, QList<ContentItem>(handler->getContentItems()));
             delete handler;
         } else {
@@ -469,7 +469,7 @@ void TitleMapThread::buildContentDict()
     if (contentOut.open(QFile::WriteOnly)) {
         QDataStream s(&contentOut);
         s << fileAges;
-        for(QList<QPair<QString, ContentList> >::Iterator it = contentList.begin(); it != contentList.end(); ++it) {
+        for (QList<QPair<QString, ContentList> >::Iterator it = contentList.begin(); it != contentList.end(); ++it) {
             s << *it;
         }
         contentOut.close();
@@ -542,12 +542,12 @@ void IndexThread::buildKeywordDB()
     QStringList::iterator i = addDocuFiles.begin();
 
     int steps = 0;
-    for(; i != addDocuFiles.end(); i++)
+    for (; i != addDocuFiles.end(); i++)
         steps += QFileInfo(*i).size();
 
     QList<IndexKeyword> lst;
     quint32 fileAges = 0;
-    for(i = addDocuFiles.begin(); i != addDocuFiles.end(); i++){
+    for (i = addDocuFiles.begin(); i != addDocuFiles.end(); i++) {
         QFile file(*i);
         if (!file.exists()) {
 #ifdef _SHOW_ERRORS_
@@ -560,7 +560,7 @@ void IndexThread::buildKeywordDB()
         DocuParser *handler = DocuParser::createParser(*i);
         bool ok = handler->parse(&file);
         file.close();
-        if(!ok){
+        if (!ok){
 #ifdef _SHOW_ERRORS_
             QString msg = QString::fromLatin1("In file %1:\n%2")
                           .arg(QFileInfo(file).absoluteFilePath())
diff --git a/src/plugins/help/helpfindsupport.cpp b/src/plugins/help/helpfindsupport.cpp
index 83ec2d1570d2c82631a0421b26363f7ac851c450..a26032ec2f5a9ade924d0704449c70555b71ff29 100644
--- a/src/plugins/help/helpfindsupport.cpp
+++ b/src/plugins/help/helpfindsupport.cpp
@@ -34,6 +34,8 @@
 #include "helpfindsupport.h"
 #include "helpviewer.h"
 
+#include <utils/qtcassert.h>
+
 using namespace Help::Internal;
 
 HelpFindSupport::HelpFindSupport(CentralWidget *centralWidget)
@@ -52,8 +54,8 @@ bool HelpFindSupport::isEnabled() const
 
 QString HelpFindSupport::currentFindString() const
 {
-    Q_ASSERT(m_centralWidget);
-    HelpViewer* viewer = m_centralWidget->currentHelpViewer();
+    QTC_ASSERT(m_centralWidget, return QString());
+    HelpViewer *viewer = m_centralWidget->currentHelpViewer();
     if (!viewer)
         return QString();
 #if !defined(QT_NO_WEBKIT)
@@ -70,13 +72,13 @@ QString HelpFindSupport::completedFindString() const
 
 bool HelpFindSupport::findIncremental(const QString &txt, QTextDocument::FindFlags findFlags)
 {
-    Q_ASSERT(m_centralWidget);
+    QTC_ASSERT(m_centralWidget, return false);
     findFlags &= ~QTextDocument::FindBackward;
     return m_centralWidget->find(txt, findFlags, true);
 }
 
 bool HelpFindSupport::findStep(const QString &txt, QTextDocument::FindFlags findFlags)
 {
-    Q_ASSERT(m_centralWidget);
+    QTC_ASSERT(m_centralWidget, return false);
     return m_centralWidget->find(txt, findFlags, false);
 }
diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp
index c96fcf28472481f727570557de9e8bb98289fe12..972ab7d6a6b16df8ccbad11f0e9885d878d68d84 100644
--- a/src/plugins/help/helpplugin.cpp
+++ b/src/plugins/help/helpplugin.cpp
@@ -512,7 +512,7 @@ void HelpPlugin::activateContext()
     // case 1 sidebar shown and has focus, we show whatever we have in the
     // sidebar in big
     RightPanePlaceHolder* placeHolder = RightPanePlaceHolder::current();
-    if(placeHolder && Core::RightPaneWidget::instance()->hasFocus()) {
+    if (placeHolder && Core::RightPaneWidget::instance()->hasFocus()) {
         switchToHelpMode();
         return;
     }
diff --git a/src/plugins/perforce/perforceeditor.cpp b/src/plugins/perforce/perforceeditor.cpp
index 8eda71843f4096fc84afb5c0e70ddc6acd39bfa6..845f8b0f74d32aadbb0c8286ef2b0990ac7f08d9 100644
--- a/src/plugins/perforce/perforceeditor.cpp
+++ b/src/plugins/perforce/perforceeditor.cpp
@@ -32,26 +32,28 @@
 ***************************************************************************/
 
 #include "perforceeditor.h"
+
 #include "annotationhighlighter.h"
-#include "perforceplugin.h"
 #include "perforceconstants.h"
 #include "perforceplugin.h"
 
-#include <vcsbase/diffhighlighter.h>
 #include <coreplugin/editormanager/editormanager.h>
+#include <utils/qtcassert.h>
+#include <vcsbase/diffhighlighter.h>
 
+#include <QtCore/QDebug>
 #include <QtCore/QFileInfo>
-#include <QtCore/QTextStream>
-#include <QtCore/QSet>
+#include <QtCore/QProcess>
 #include <QtCore/QRegExp>
-#include <QtCore/QDebug>
+#include <QtCore/QSet>
+#include <QtCore/QTextStream>
+
+#include <QtGui/QAction>
 #include <QtGui/QKeyEvent>
 #include <QtGui/QLayout>
-#include <QtGui/QTextEdit>
 #include <QtGui/QMenu>
-#include <QtGui/QAction>
 #include <QtGui/QTextCursor>
-#include <QtCore/QProcess>
+#include <QtGui/QTextEdit>
 
 namespace Perforce {
 namespace Internal {
@@ -63,7 +65,7 @@ PerforceEditor::PerforceEditor(const VCSBase::VCSBaseEditorParameters *type,
     m_changeNumberPattern(QLatin1String("^\\d+$")),
     m_plugin(PerforcePlugin::perforcePluginInstance())
 {
-    Q_ASSERT(m_changeNumberPattern.isValid());
+    QTC_ASSERT(m_changeNumberPattern.isValid(), /**/);
     if (Perforce::Constants::debug)
         qDebug() << "PerforceEditor::PerforceEditor" << type->type << type->kind;
 }
@@ -76,11 +78,11 @@ QSet<QString> PerforceEditor::annotationChanges() const
         return changes;
     // Hunt for first change number in annotation: "<change>:"
     QRegExp r(QLatin1String("^(\\d+):"));
-    Q_ASSERT(r.isValid());
+    QTC_ASSERT(r.isValid(), return changes);
     if (r.indexIn(txt) != -1) {
         changes.insert(r.cap(1));
         r.setPattern(QLatin1String("\n(\\d+):"));
-        Q_ASSERT(r.isValid());
+        QTC_ASSERT(r.isValid(), return changes);
         int pos = 0;
         while ((pos = r.indexIn(txt, pos)) != -1) {
             pos += r.matchedLength();
diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp
index dc28901b7050540b8dc028165ccf658308a0c493..c609c35bf0e7752a4746b559c03a849aec0fb3e8 100644
--- a/src/plugins/perforce/perforceplugin.cpp
+++ b/src/plugins/perforce/perforceplugin.cpp
@@ -31,25 +31,27 @@
 **
 ***************************************************************************/
 
-#include "p4.h"
 #include "perforceplugin.h"
-#include "perforceoutputwindow.h"
-#include "settingspage.h"
-#include "perforcesubmiteditor.h"
+
 #include "changenumberdialog.h"
+#include "p4.h"
+#include "pendingchangesdialog.h"
 #include "perforceconstants.h"
-#include "perforceversioncontrol.h"
 #include "perforceeditor.h"
-#include "pendingchangesdialog.h"
+#include "perforceoutputwindow.h"
+#include "perforcesubmiteditor.h"
+#include "perforceversioncontrol.h"
+#include "settingspage.h"
 
-#include <coreplugin/icore.h>
+#include <coreplugin/actionmanager/actionmanagerinterface.h>
 #include <coreplugin/coreconstants.h>
-#include <coreplugin/mimedatabase.h>
+#include <coreplugin/editormanager/editormanager.h>
 #include <coreplugin/filemanager.h>
+#include <coreplugin/icore.h>
 #include <coreplugin/messagemanager.h>
+#include <coreplugin/mimedatabase.h>
 #include <coreplugin/uniqueidmanager.h>
-#include <coreplugin/actionmanager/actionmanagerinterface.h>
-#include <coreplugin/editormanager/editormanager.h>
+#include <utils/qtcassert.h>
 #include <utils/synchronousprocess.h>
 #include <vcsbase/basevcseditorfactory.h>
 #include <vcsbase/basevcssubmiteditorfactory.h>
@@ -57,16 +59,17 @@
 
 #include <QtCore/qplugin.h>
 #include <QtCore/QDebug>
-#include <QtCore/QFileInfo>
-#include <QtCore/QTemporaryFile>
 #include <QtCore/QDir>
+#include <QtCore/QFileInfo>
 #include <QtCore/QSettings>
+#include <QtCore/QTemporaryFile>
 #include <QtCore/QTextCodec>
+
 #include <QtGui/QAction>
+#include <QtGui/QFileDialog>
+#include <QtGui/QMainWindow>
 #include <QtGui/QMenu>
 #include <QtGui/QMessageBox>
-#include <QtGui/QMainWindow>
-#include <QtGui/QFileDialog>
 
 using namespace Perforce::Internal;
 
@@ -420,7 +423,7 @@ void PerforcePlugin::deleteCurrentFile()
 
 void PerforcePlugin::revertCurrentFile()
 {
-    Q_ASSERT(m_coreInstance);
+    QTC_ASSERT(m_coreInstance, return);
 
     const QString fileName = currentFileName();
     QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(m_coreInstance, fileName);
@@ -460,7 +463,7 @@ void PerforcePlugin::diffCurrentFile()
 
 void PerforcePlugin::diffCurrentProject()
 {
-    Q_ASSERT(m_projectExplorer);
+    QTC_ASSERT(m_projectExplorer, return);
     QStringList files;
     QString name;
     ProjectExplorer::Project *currentProject = m_projectExplorer->currentProject();
@@ -502,7 +505,8 @@ void PerforcePlugin::resolve()
 
 void PerforcePlugin::submit()
 {
-    Q_ASSERT(m_coreInstance);
+    QTC_ASSERT(m_coreInstance, return);
+
     if (!checkP4Command()) {
         showOutput(tr("No p4 executable specified!"));
         return;
@@ -534,7 +538,7 @@ void PerforcePlugin::submit()
     m_changeTmpFile->seek(0);
 
     // Assemble file list of project
-    Q_ASSERT(m_projectExplorer);
+    QTC_ASSERT(m_projectExplorer, return);
     QStringList files;
     QString name;
     ProjectExplorer::Project *currentProject = m_projectExplorer->currentProject();
@@ -561,10 +565,9 @@ void PerforcePlugin::submit()
 
     QStringList stdOutLines = result2.stdOut.split(QLatin1Char('\n'));
     QStringList depotFileNames;
-    foreach(const QString &line, stdOutLines) {
-        if (line.startsWith("... depotFile")) {
+    foreach (const QString &line, stdOutLines) {
+        if (line.startsWith("... depotFile"))
             depotFileNames.append(line.mid(14));
-        }
     }
     if (depotFileNames.isEmpty()) {
         showOutput(tr("Project has no files"));
@@ -582,7 +585,7 @@ Core::IEditor *PerforcePlugin::openPerforceSubmitEditor(const QString &fileName,
             m_coreInstance->editorManager()->openEditor(fileName, Constants::PERFORCESUBMITEDITOR_KIND);
     m_coreInstance->editorManager()->ensureEditorManagerVisible();
     PerforceSubmitEditor *submitEditor = dynamic_cast<PerforceSubmitEditor*>(editor);
-    Q_ASSERT(submitEditor);
+    QTC_ASSERT(submitEditor, return 0);
     submitEditor->restrictToProjectFiles(depotFileNames);
     connect(submitEditor, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(slotDiff(QStringList)));
     // The actions are for some reason enabled by the context switching
@@ -736,7 +739,7 @@ QString PerforcePlugin::findTopLevelForDirectory(const QString & /* dir */) cons
         return QString::null;
 
     QRegExp regExp(QLatin1String("(\\n|\\r\\n|\\r)Root:\\s*(.*)(\\n|\\r\\n|\\r)"));
-    Q_ASSERT(regExp.isValid());
+    QTC_ASSERT(regExp.isValid(), /**/);
     regExp.setMinimal(true);
     if (regExp.indexIn(result.stdOut) != -1) {
         QString file = regExp.cap(2).trimmed();
@@ -785,7 +788,7 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args,
         qDebug() << "PerforcePlugin::runP4Cmd" << args << extraArgs << debugCodec(outputCodec);
     PerforceResponse response;
     response.error = true;
-    Q_ASSERT(m_coreInstance);
+    QTC_ASSERT(m_coreInstance, return response);
     if (!checkP4Command()) {
         response.message = tr("No p4 executable specified!");
         m_perforceOutputWindow->append(response.message, true);
@@ -875,7 +878,7 @@ Core::IEditor * PerforcePlugin::showOutputInEditor(const QString& title, const Q
                                                    int editorType, QTextCodec *codec)
 {
     const VCSBase::VCSBaseEditorParameters *params = findType(editorType);
-    Q_ASSERT(params);
+    QTC_ASSERT(params, return 0);
     const QString kind = QLatin1String(params->kind);
     if (Perforce::Constants::debug)
         qDebug() << "PerforcePlugin::showOutputInEditor" << title << kind <<  "Size= " << output.size() <<  " Type=" << editorType << debugCodec(codec);
@@ -1048,10 +1051,9 @@ void PerforcePlugin::openFiles(const QStringList &files)
 
 QString PerforcePlugin::clientFilePath(const QString &serverFilePath)
 {
-    QString path;
-    Q_ASSERT(m_coreInstance);
+    QTC_ASSERT(m_coreInstance, return QString());
     if (!checkP4Command())
-        return path;
+        return QString();
 
     QApplication::setOverrideCursor(Qt::WaitCursor);
     QProcess proc;
@@ -1059,6 +1061,7 @@ QString PerforcePlugin::clientFilePath(const QString &serverFilePath)
     proc.start(m_settings.p4Command,
         basicP4Args() << QLatin1String("fstat") << serverFilePath);
 
+    QString path;
     if (proc.waitForFinished(3000)) {
         QString output = QString::fromUtf8(proc.readAllStandardOutput());
         if (!output.isEmpty()) {
@@ -1225,7 +1228,7 @@ PerforcePlugin::~PerforcePlugin()
     }
 
     if (!m_editorFactories.empty()) {
-        foreach(Core::IEditorFactory* pf, m_editorFactories)
+        foreach (Core::IEditorFactory *pf, m_editorFactories)
             removeObject(pf);
         qDeleteAll(m_editorFactories);
         m_editorFactories.clear();
@@ -1285,5 +1288,17 @@ QString PerforcePlugin::fileNameFromPerforceName(const QString& perforceName,
     return rc;
 }
 
+Core::ICore *PerforcePlugin::coreInstance()
+{       
+    QTC_ASSERT(m_coreInstance, return 0);
+    return m_coreInstance;
+}
+
+PerforcePlugin *PerforcePlugin::perforcePluginInstance()
+{
+    QTC_ASSERT(m_perforcePluginInstance, return 0);
+    return m_perforcePluginInstance;
+}
+
 Q_EXPORT_PLUGIN(PerforcePlugin)
 
diff --git a/src/plugins/perforce/perforceplugin.h b/src/plugins/perforce/perforceplugin.h
index 7a4e23077794ef89599d00b3818d537fb118c46a..11301853b9d5e589234ae55cc1aa55d82bb095c6 100644
--- a/src/plugins/perforce/perforceplugin.h
+++ b/src/plugins/perforce/perforceplugin.h
@@ -100,7 +100,7 @@ public:
     ~PerforcePlugin();
 
     QStringList basicP4Args() const;
-    inline SettingsPage *settingsPage() const { return m_settingsPage; }
+    SettingsPage *settingsPage() const { return m_settingsPage; }
 
     bool initialize(const QStringList &arguments, QString *error_message);
     void extensionsInitialized();
@@ -117,8 +117,8 @@ public:
 
     Core::IEditor *openPerforceSubmitEditor(const QString &fileName, const QStringList &depotFileNames);
 
-    static Core::ICore *coreInstance() {Q_ASSERT(m_coreInstance); return m_coreInstance;}
-    static PerforcePlugin *perforcePluginInstance() {Q_ASSERT(m_perforcePluginInstance); return m_perforcePluginInstance;}
+    static Core::ICore *coreInstance();
+    static PerforcePlugin *perforcePluginInstance();
 
     PerforceSettings settings() const;
     void setSettings(const PerforceSettings &s);
diff --git a/src/plugins/perforce/perforcesubmiteditor.cpp b/src/plugins/perforce/perforcesubmiteditor.cpp
index 4dc41e7fa5e4479dc8c4b419ceafb95d9b8293c3..035ffe2462114f2df25ac966b8f9ae8db2214f87 100644
--- a/src/plugins/perforce/perforcesubmiteditor.cpp
+++ b/src/plugins/perforce/perforcesubmiteditor.cpp
@@ -36,6 +36,8 @@
 #include "perforceplugin.h"
 #include "perforceconstants.h"
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/QDebug>
 
 namespace Perforce {
@@ -153,7 +155,7 @@ void PerforceSubmitEditor::updateFields()
     lines.removeLast(); // that is the empty line at the end
 
     const QRegExp leadingTabPattern = QRegExp(QLatin1String("^\\t"));
-    Q_ASSERT(leadingTabPattern.isValid());
+    QTC_ASSERT(leadingTabPattern.isValid(), /**/);
 
     lines.replaceInStrings(leadingTabPattern, QString());
     widget->setDescriptionText(lines.join(newLine));
diff --git a/src/plugins/projectexplorer/abstractprocessstep.cpp b/src/plugins/projectexplorer/abstractprocessstep.cpp
index 06b40135c1262da635ecd62f21b5ec24364c7e5f..965a8b4c0c4649346008f2a59547df407c22f19b 100644
--- a/src/plugins/projectexplorer/abstractprocessstep.cpp
+++ b/src/plugins/projectexplorer/abstractprocessstep.cpp
@@ -112,7 +112,7 @@ bool AbstractProcessStep::init(const QString &name)
 void AbstractProcessStep::run(QFutureInterface<bool> & fi)
 {
     m_futureInterface = &fi;
-    if(!m_enabled) {
+    if (!m_enabled) {
         fi.reportResult(true);
         return;
     }
@@ -136,7 +136,7 @@ void AbstractProcessStep::run(QFutureInterface<bool> & fi)
             Qt::DirectConnection);
 
     m_process->start(m_command, m_arguments);
-    if(!m_process->waitForStarted()) {
+    if (!m_process->waitForStarted()) {
         processStartupFailed();
         delete m_process;
         m_process = 0;
@@ -188,8 +188,7 @@ void AbstractProcessStep::processStartupFailed()
 void AbstractProcessStep::processReadyReadStdOutput()
 {
     m_process->setReadChannel(QProcess::StandardOutput);
-    while(m_process->canReadLine())
-    {
+    while (m_process->canReadLine()) {
         QString line = QString::fromLocal8Bit(m_process->readLine()).trimmed();
         stdOut(line);
     }
@@ -203,8 +202,7 @@ void AbstractProcessStep::stdOut(const QString &line)
 void AbstractProcessStep::processReadyReadStdError()
 {
     m_process->setReadChannel(QProcess::StandardError);
-    while (m_process->canReadLine())
-    {
+    while (m_process->canReadLine()) {
         QString line = QString::fromLocal8Bit(m_process->readLine()).trimmed();
         stdError(line);
     }
@@ -217,7 +215,7 @@ void AbstractProcessStep::stdError(const QString &line)
 
 void AbstractProcessStep::checkForCancel()
 {
-    if(m_futureInterface->isCanceled() && m_timer->isActive()) {
+    if (m_futureInterface->isCanceled() && m_timer->isActive()) {
         m_timer->stop();
         m_process->terminate();
         m_process->waitForFinished(5000);
@@ -228,13 +226,12 @@ void AbstractProcessStep::checkForCancel()
 void AbstractProcessStep::slotProcessFinished(int, QProcess::ExitStatus)
 {
     QString line = QString::fromLocal8Bit(m_process->readAllStandardError()).trimmed();
-    if (!line.isEmpty()) {
+    if (!line.isEmpty())
         stdOut(line);
-    }
 
     line = QString::fromLocal8Bit(m_process->readAllStandardOutput()).trimmed();
-    if (!line.isEmpty()) {
+    if (!line.isEmpty())
         stdError(line);
-    }
+
     m_eventLoop->exit(0);
 }
diff --git a/src/plugins/projectexplorer/allprojectsfind.cpp b/src/plugins/projectexplorer/allprojectsfind.cpp
index be7d9d96ee452ae48e8c82ac2ef386a8a986e859..a7832ca6796aa1827fc85d20c0e695050815f7ab 100644
--- a/src/plugins/projectexplorer/allprojectsfind.cpp
+++ b/src/plugins/projectexplorer/allprojectsfind.cpp
@@ -32,10 +32,13 @@
 ***************************************************************************/
 
 #include "allprojectsfind.h"
-#include "projectexplorer.h"
+
 #include "project.h"
+#include "projectexplorer.h"
+
+#include <utils/qtcassert.h>
 
-#include <QtDebug>
+#include <QtCore/QDebug>
 #include <QtCore/QRegExp>
 #include <QtGui/QGridLayout>
 
@@ -71,9 +74,7 @@ QKeySequence AllProjectsFind::defaultShortcut() const
 
 QStringList AllProjectsFind::files()
 {
-    Q_ASSERT(m_plugin->session());
-    if (!m_plugin->session())
-        return QStringList();
+    QTC_ASSERT(m_plugin->session(), return QStringList());
     QList<QRegExp> filterRegs;
     QStringList nameFilters = fileNameFilters();
     foreach (const QString &filter, nameFilters) {
diff --git a/src/plugins/projectexplorer/applicationrunconfiguration.cpp b/src/plugins/projectexplorer/applicationrunconfiguration.cpp
index 30b9a7f7caab9ec98223e647ef13ccd392e9f71b..88bbd64116458d6067de78f1dd0c9550b4cd7d51 100644
--- a/src/plugins/projectexplorer/applicationrunconfiguration.cpp
+++ b/src/plugins/projectexplorer/applicationrunconfiguration.cpp
@@ -36,6 +36,7 @@
 #include "environment.h"
 
 #include <projectexplorer/projectexplorerconstants.h>
+#include <utils/qtcassert.h>
 
 #include <QtGui/QLabel>
 #include <QtGui/QTextDocument>
@@ -94,8 +95,8 @@ QString ApplicationRunConfigurationRunner::displayName() const
 RunControl* ApplicationRunConfigurationRunner::run(QSharedPointer<RunConfiguration> runConfiguration, const QString &mode)
 {
     QSharedPointer<ApplicationRunConfiguration> rc = qSharedPointerCast<ApplicationRunConfiguration>(runConfiguration);
-    Q_ASSERT(rc);
-    Q_ASSERT(mode == ProjectExplorer::Constants::RUNMODE);
+    QTC_ASSERT(rc, return 0);
+    QTC_ASSERT(mode == ProjectExplorer::Constants::RUNMODE, return 0);
 
     ApplicationRunControl *runControl = new ApplicationRunControl(rc);
     return runControl;
@@ -112,10 +113,10 @@ QWidget *ApplicationRunConfigurationRunner::configurationWidget(QSharedPointer<R
 ApplicationRunControl::ApplicationRunControl(QSharedPointer<ApplicationRunConfiguration> runConfiguration)
     : RunControl(runConfiguration), m_applicationLauncher()
 {
-    connect(&m_applicationLauncher, SIGNAL(applicationError(const QString &)),
-            this, SLOT(slotError(const QString &)));
-    connect(&m_applicationLauncher, SIGNAL(appendOutput(const QString &)),
-            this, SLOT(slotAddToOutputWindow(const QString &)));
+    connect(&m_applicationLauncher, SIGNAL(applicationError(QString)),
+            this, SLOT(slotError(QString)));
+    connect(&m_applicationLauncher, SIGNAL(appendOutput(QString)),
+            this, SLOT(slotAddToOutputWindow(QString)));
     connect(&m_applicationLauncher, SIGNAL(processExited(int)),
             this, SLOT(processExited(int)));
     connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)),
@@ -129,7 +130,7 @@ ApplicationRunControl::~ApplicationRunControl()
 void ApplicationRunControl::start()
 {
     QSharedPointer<ApplicationRunConfiguration> rc = qSharedPointerCast<ApplicationRunConfiguration>(runConfiguration());
-    Q_ASSERT(rc);
+    QTC_ASSERT(rc, return);
 
     m_applicationLauncher.setEnvironment(rc->environment().toStringList());
     m_applicationLauncher.setWorkingDirectory(rc->workingDirectory());
diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp
index c9090723a19b05d2d2b944ad778df049ddcfdcb2..c960cb0e34c09828faac59f2c153ca515d743be7 100644
--- a/src/plugins/projectexplorer/buildconfiguration.cpp
+++ b/src/plugins/projectexplorer/buildconfiguration.cpp
@@ -42,9 +42,8 @@ BuildConfiguration::BuildConfiguration(const QString &name)
 }
 
 BuildConfiguration::BuildConfiguration(const QString &name, BuildConfiguration *source)
-    :m_values(source->m_values), m_name(name)
+    : m_values(source->m_values), m_name(name)
 {
-
 }
 
 QString BuildConfiguration::name() const
@@ -71,7 +70,7 @@ void BuildConfiguration::setDisplayName(const QString &name)
 QVariant BuildConfiguration::getValue(const QString & key) const
 {
     QHash<QString, QVariant>::const_iterator it = m_values.find(key);
-    if(it != m_values.constEnd())
+    if (it != m_values.constEnd())
         return *it;
     else
         return QVariant();
@@ -86,7 +85,7 @@ void BuildConfiguration::setValuesFromMap(QMap<QString, QVariant> map)
 {
     QMap<QString, QVariant>::const_iterator it, end;
     end = map.constEnd();
-    for(it = map.constBegin(); it != end; ++it)
+    for (it = map.constBegin(); it != end; ++it)
         setValue(it.key(), it.value());
 }
 
@@ -95,7 +94,7 @@ QMap<QString, QVariant> BuildConfiguration::toMap() const
     QMap<QString, QVariant> result;
     QHash<QString, QVariant>::const_iterator it, end;
     end = m_values.constEnd();
-    for(it = m_values.constBegin(); it != end; ++it)
+    for (it = m_values.constBegin(); it != end; ++it)
         result.insert(it.key(), it.value());
     return result;
 }
diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp
index 98002f882709e4088110ebf9af28dba5d2222bd3..c6f386fa41320a673142e38af96d0531575995e1 100644
--- a/src/plugins/projectexplorer/buildmanager.cpp
+++ b/src/plugins/projectexplorer/buildmanager.cpp
@@ -32,16 +32,18 @@
 ***************************************************************************/
 
 #include "buildmanager.h"
+
+#include "buildprogress.h"
 #include "buildstep.h"
 #include "compileoutputwindow.h"
-#include "taskwindow.h"
-#include "projectexplorer.h"
 #include "projectexplorerconstants.h"
-#include "buildprogress.h"
+#include "projectexplorer.h"
+#include "taskwindow.h"
 
-#include <extensionsystem/pluginmanager.h>
 #include <coreplugin/progressmanager/progressmanagerinterface.h>
 #include <coreplugin/progressmanager/futureprogress.h>
+#include <extensionsystem/pluginmanager.h>
+#include <utils/qtcassert.h>
 
 #include <QtCore/QDir>
 #include <QtCore/QTimer>
@@ -300,7 +302,7 @@ void BuildManager::buildQueueAppend(BuildStep * bs, const QString &configuration
 
 void BuildManager::buildProjects(const QList<Project *> &projects, const QList<QString> &configurations)
 {
-    Q_ASSERT(projects.count() == configurations.count());
+    QTC_ASSERT(projects.count() == configurations.count(), /**/);
     QList<QString>::const_iterator cit = configurations.constBegin();
     QList<Project *>::const_iterator it, end;
     end = projects.constEnd();
@@ -316,7 +318,7 @@ void BuildManager::buildProjects(const QList<Project *> &projects, const QList<Q
 
 void BuildManager::cleanProjects(const QList<Project *> &projects, const QList<QString> &configurations)
 {
-    Q_ASSERT(projects.count() == configurations.count());
+    QTC_ASSERT(projects.count() == configurations.count(), /**/);
     QList<QString>::const_iterator cit = configurations.constBegin();
     QList<Project *>::const_iterator it, end;
     end = projects.constEnd();
@@ -376,7 +378,7 @@ void BuildManager::decrementActiveBuildSteps(Project *pro)
     QHash<Project *, int>::iterator it = m_activeBuildSteps.find(pro);
     QHash<Project *, int>::iterator end = m_activeBuildSteps.end();
     if (it == end) {
-        Q_ASSERT(false && "BuildManager m_activeBuildSteps says project is not building, but apparently a build step was still in the queue.");
+        QTC_ASSERT(false && "BuildManager m_activeBuildSteps says project is not building, but apparently a build step was still in the queue.", return);
     } else if (*it == 1) {
         --*it;
         emit buildStateChanged(pro);
diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp
index a713fdc773ea3f494c083850b29db6bb9ba9929f..2c1434534be646963078c679bc78caa11343b5b4 100644
--- a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp
+++ b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp
@@ -142,7 +142,7 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project)
 void BuildSettingsWidget::buildConfigurationDisplayNameChanged(const QString &buildConfiguration)
 {
     QTreeWidgetItem *rootItem = m_ui.buildSettingsList->invisibleRootItem();
-    for(int i = 0; i < rootItem->childCount(); ++i) {
+    for (int i = 0; i < rootItem->childCount(); ++i) {
         QTreeWidgetItem *child = rootItem->child(i);
         if (child->data(0, Qt::UserRole).toString() == buildConfiguration) {
             child->setText(0, m_project->displayNameFor(buildConfiguration));
@@ -334,7 +334,7 @@ void BuildSettingsWidget::createConfiguration()
 {
     bool ok;
     QString newBuildConfiguration = QInputDialog::getText(this, tr("New configuration"), tr("New Configuration Name:"), QLineEdit::Normal, QString(), &ok);
-    if(!ok || newBuildConfiguration.isEmpty())
+    if (!ok || newBuildConfiguration.isEmpty())
         return;
 
     QString newDisplayName = newBuildConfiguration;
@@ -342,22 +342,20 @@ void BuildSettingsWidget::createConfiguration()
     const QStringList &buildConfigurations = m_project->buildConfigurations();
     if (buildConfigurations.contains(newBuildConfiguration)) {
         int i = 2;
-        while(buildConfigurations.contains(newBuildConfiguration + QString::number(i))) {
+        while (buildConfigurations.contains(newBuildConfiguration + QString::number(i)))
             ++i;
-        }
         newBuildConfiguration += QString::number(i);
     }
 
     // Check that we don't have a configuration with the same displayName
     QStringList displayNames;
-    foreach(const QString &bc, buildConfigurations)
+    foreach (const QString &bc, buildConfigurations)
         displayNames << m_project->displayNameFor(bc);
 
     if (displayNames.contains(newDisplayName)) {
         int i = 2;
-        while(displayNames.contains(newDisplayName + QString::number(i))) {
+        while (displayNames.contains(newDisplayName + QString::number(i)))
             ++i;
-        }
         newDisplayName += QString::number(i);
     }
 
@@ -407,11 +405,11 @@ void BuildSettingsWidget::setActiveConfiguration(const QString &configuration)
 
 void BuildSettingsWidget::cloneConfiguration(const QString &sourceConfiguration)
 {
-    if(sourceConfiguration.isEmpty())
+    if (sourceConfiguration.isEmpty())
         return;
 
     QString newBuildConfiguration = QInputDialog::getText(this, tr("Clone configuration"), tr("New Configuration Name:"));
-    if(newBuildConfiguration.isEmpty())
+    if (newBuildConfiguration.isEmpty())
         return;
 
     QString newDisplayName = newBuildConfiguration;
@@ -419,22 +417,20 @@ void BuildSettingsWidget::cloneConfiguration(const QString &sourceConfiguration)
     const QStringList &buildConfigurations = m_project->buildConfigurations();
     if (buildConfigurations.contains(newBuildConfiguration)) {
         int i = 2;
-        while(buildConfigurations.contains(newBuildConfiguration + QString::number(i))) {
+        while (buildConfigurations.contains(newBuildConfiguration + QString::number(i)))
             ++i;
-        }
         newBuildConfiguration += QString::number(i);
     }
 
     // Check that we don't have a configuration with the same displayName
     QStringList displayNames;
-    foreach(const QString &bc, buildConfigurations)
+    foreach (const QString &bc, buildConfigurations)
         displayNames << m_project->displayNameFor(bc);
 
     if (displayNames.contains(newDisplayName)) {
         int i = 2;
-        while(displayNames.contains(newDisplayName + QString::number(i))) {
+        while (displayNames.contains(newDisplayName + QString::number(i)))
             ++i;
-        }
         newDisplayName += QString::number(i);
     }
 
diff --git a/src/plugins/projectexplorer/buildstep.cpp b/src/plugins/projectexplorer/buildstep.cpp
index 474306dd57a840dbac86ca0e5063b9694488491d..ef1dec4d2cb4b66ec995a91badb1ec5968f78b8c 100644
--- a/src/plugins/projectexplorer/buildstep.cpp
+++ b/src/plugins/projectexplorer/buildstep.cpp
@@ -34,6 +34,8 @@
 #include "buildstep.h"
 #include "buildconfiguration.h"
 
+#include <utils/qtcassert.h>
+
 namespace ProjectExplorer {
 
 BuildStep::BuildStep(Project * pro)
@@ -60,8 +62,8 @@ void BuildStep::addBuildConfiguration(const QString &name)
 
 void BuildStep::removeBuildConfiguration(const QString &name)
 {
-    for(int i = 0; i != m_buildConfigurations.size(); ++i)
-        if(m_buildConfigurations.at(i)->name() == name) {
+    for (int i = 0; i != m_buildConfigurations.size(); ++i)
+        if (m_buildConfigurations.at(i)->name() == name) {
             delete m_buildConfigurations.at(i);
             m_buildConfigurations.removeAt(i);
             break;
@@ -70,15 +72,15 @@ void BuildStep::removeBuildConfiguration(const QString &name)
 
 void BuildStep::copyBuildConfiguration(const QString &source, const QString &dest)
 {
-    for(int i = 0; i != m_buildConfigurations.size(); ++i)
-        if(m_buildConfigurations.at(i)->name() == source)
+    for (int i = 0; i != m_buildConfigurations.size(); ++i)
+        if (m_buildConfigurations.at(i)->name() == source)
             m_buildConfigurations.push_back(new BuildConfiguration(dest, m_buildConfigurations.at(i)));
 }
 
 void BuildStep::setValue(const QString &buildConfiguration, const QString &name, const QVariant &value)
 {
     BuildConfiguration *bc = getBuildConfiguration(buildConfiguration);
-    Q_ASSERT(bc);
+    QTC_ASSERT(bc, return);
     bc->setValue(name, value);
 }
 
diff --git a/src/plugins/projectexplorer/buildstepspage.cpp b/src/plugins/projectexplorer/buildstepspage.cpp
index 6578d76e351fc0957d40faf93c8a7ff92f1618d8..a0e103ebca5ed1276f4ed9f434aeecdc97f6e496 100644
--- a/src/plugins/projectexplorer/buildstepspage.cpp
+++ b/src/plugins/projectexplorer/buildstepspage.cpp
@@ -32,10 +32,12 @@
 ***************************************************************************/
 
 #include "buildstepspage.h"
+
 #include "ui_buildstepspage.h"
 #include "project.h"
 
 #include <extensionsystem/pluginmanager.h>
+#include <utils/qtcassert.h>
 
 using namespace ProjectExplorer;
 using namespace ProjectExplorer::Internal;
@@ -119,17 +121,16 @@ void BuildStepsPage::init(const QString &buildConfiguration)
 /* switch from one tree item / build step to another */
 void BuildStepsPage::updateBuildStepWidget(QTreeWidgetItem *newItem, QTreeWidgetItem *oldItem)
 {
-    if(oldItem == newItem)
+    if (oldItem == newItem)
         return;
-    Q_ASSERT(m_pro);
+    QTC_ASSERT(m_pro, return);
 
-    if(newItem) {
+    if (newItem) {
         int row = m_ui->buildSettingsList->indexOfTopLevelItem(newItem);
         m_ui->buildSettingsWidget->setCurrentIndex(row);
         BuildStepConfigWidget *widget = qobject_cast<BuildStepConfigWidget *>(m_ui->buildSettingsWidget->currentWidget());
-        Q_ASSERT(widget);
-        if (widget)
-         widget->init(m_configuration);
+        QTC_ASSERT(widget, return);
+        widget->init(m_configuration);
     }
     updateBuildStepButtonsState();
 }
@@ -151,11 +152,11 @@ void BuildStepsPage::updateAddBuildStepMenu()
     QMenu *menu = m_ui->buildStepAddButton->menu();
     m_addBuildStepHash.clear();
     menu->clear();
-    if(!map.isEmpty()) {
+    if (!map.isEmpty()) {
         QStringList names;
         QMap<QString, QPair<QString, IBuildStepFactory *> >::const_iterator it, end;
         end = map.constEnd();
-        for(it = map.constBegin(); it != end; ++it) {
+        for (it = map.constBegin(); it != end; ++it) {
             QAction *action = menu->addAction(it.key());
             connect(action, SIGNAL(triggered()),
                     this, SLOT(addBuildStep()));
@@ -167,7 +168,7 @@ void BuildStepsPage::updateAddBuildStepMenu()
 
 void BuildStepsPage::addBuildStep()
 {
-    if(QAction *action = qobject_cast<QAction *>(sender())) {
+    if (QAction *action = qobject_cast<QAction *>(sender())) {
         QPair<QString, IBuildStepFactory *> pair = m_addBuildStepHash.value(action);
         BuildStep *newStep = pair.second->create(m_pro, pair.first);
         m_pro->insertBuildStep(0, newStep);
@@ -182,7 +183,7 @@ void BuildStepsPage::addBuildStep()
 void BuildStepsPage::removeBuildStep()
 {
     int pos = m_ui->buildSettingsList->currentIndex().row();
-    if(m_pro->buildSteps().at(pos)->immutable())
+    if (m_pro->buildSteps().at(pos)->immutable())
         return;
     bool blockSignals = m_ui->buildSettingsList->blockSignals(true);
     delete m_ui->buildSettingsList->invisibleRootItem()->takeChild(pos);
@@ -190,7 +191,7 @@ void BuildStepsPage::removeBuildStep()
     QWidget *widget = m_ui->buildSettingsWidget->widget(pos);
     m_ui->buildSettingsWidget->removeWidget(widget);
     delete widget;
-    if(pos < m_ui->buildSettingsList->invisibleRootItem()->childCount())
+    if (pos < m_ui->buildSettingsList->invisibleRootItem()->childCount())
         m_ui->buildSettingsList->setCurrentItem(m_ui->buildSettingsList->invisibleRootItem()->child(pos));
     else
         m_ui->buildSettingsList->setCurrentItem(m_ui->buildSettingsList->invisibleRootItem()->child(pos - 1));
@@ -201,11 +202,11 @@ void BuildStepsPage::removeBuildStep()
 void BuildStepsPage::upBuildStep()
 {
     int pos = m_ui->buildSettingsList->currentIndex().row();
-    if(pos < 1)
+    if (pos < 1)
         return;
-    if(pos > m_ui->buildSettingsList->invisibleRootItem()->childCount()-1)
+    if (pos > m_ui->buildSettingsList->invisibleRootItem()->childCount()-1)
         return;
-    if(m_pro->buildSteps().at(pos)->immutable() && m_pro->buildSteps().at(pos-1)->immutable())
+    if (m_pro->buildSteps().at(pos)->immutable() && m_pro->buildSteps().at(pos-1)->immutable())
         return;
 
     bool blockSignals = m_ui->buildSettingsList->blockSignals(true);
@@ -220,11 +221,11 @@ void BuildStepsPage::upBuildStep()
 void BuildStepsPage::downBuildStep()
 {
     int pos = m_ui->buildSettingsList->currentIndex().row() + 1;
-    if(pos < 1)
+    if (pos < 1)
         return;
-    if(pos > m_ui->buildSettingsList->invisibleRootItem()->childCount() - 1)
+    if (pos > m_ui->buildSettingsList->invisibleRootItem()->childCount() - 1)
         return;
-    if(m_pro->buildSteps().at(pos)->immutable() && m_pro->buildSteps().at(pos - 1)->immutable())
+    if (m_pro->buildSteps().at(pos)->immutable() && m_pro->buildSteps().at(pos - 1)->immutable())
         return;
 
     bool blockSignals = m_ui->buildSettingsList->blockSignals(true);
@@ -238,7 +239,7 @@ void BuildStepsPage::downBuildStep()
 
 void BuildStepsPage::changeEvent(QEvent *e)
 {
-    switch(e->type()) {
+    switch (e->type()) {
     case QEvent::LanguageChange:
         m_ui->retranslateUi(this);
         break;
diff --git a/src/plugins/projectexplorer/currentprojectfind.cpp b/src/plugins/projectexplorer/currentprojectfind.cpp
index fb55df3e0fd7a6f1e9710e9cf0884b6ea288111c..bcef3183b9ca1397dcfc6679ab21d13ed08dfe26 100644
--- a/src/plugins/projectexplorer/currentprojectfind.cpp
+++ b/src/plugins/projectexplorer/currentprojectfind.cpp
@@ -32,10 +32,13 @@
 ***************************************************************************/
 
 #include "currentprojectfind.h"
+
 #include "projectexplorer.h"
 #include "project.h"
 
-#include <QtDebug>
+#include <utils/qtcassert.h>
+
+#include <QtCore/QDebug>
 #include <QtCore/QRegExp>
 #include <QtGui/QGridLayout>
 
@@ -71,9 +74,7 @@ QKeySequence CurrentProjectFind::defaultShortcut() const
 QStringList CurrentProjectFind::files()
 {
     Project *project = m_plugin->currentProject();
-    Q_ASSERT(project);
-    if (!project)
-        return QStringList();
+    QTC_ASSERT(project, return QStringList());
     QList<QRegExp> filterRegs;
     QStringList nameFilters = fileNameFilters();
     foreach (const QString &filter, nameFilters) {
diff --git a/src/plugins/projectexplorer/environment.cpp b/src/plugins/projectexplorer/environment.cpp
index a8470d3df5d11579d2c5a20cc3f6646013bbeef3..b428ed3a92d79b29e85f12f77b8ef245b39dea5d 100644
--- a/src/plugins/projectexplorer/environment.cpp
+++ b/src/plugins/projectexplorer/environment.cpp
@@ -45,7 +45,7 @@ QList<EnvironmentItem> EnvironmentItem::fromStringList(QStringList list)
     QList<EnvironmentItem> result;
     foreach (const QString &string, list) {
         int pos = string.indexOf(QLatin1Char('='));
-        if(pos == -1) {
+        if (pos == -1) {
             EnvironmentItem item(string, "");
             item.unset = true;
             result.append(item);
@@ -61,7 +61,7 @@ QStringList EnvironmentItem::toStringList(QList<EnvironmentItem> list)
 {
     QStringList result;
     foreach (const EnvironmentItem &item, list) {
-        if(item.unset)
+        if (item.unset)
             result << QString(item.name);
         else
             result << QString(item.name + '=' + item.value);
@@ -71,14 +71,13 @@ QStringList EnvironmentItem::toStringList(QList<EnvironmentItem> list)
 
 Environment::Environment()
 {
-
 }
 
 Environment::Environment(QStringList env)
 {
-    foreach(QString s, env) {
+    foreach (const QString &s, env) {
         int i = s.indexOf("=");
-        if (i >=0 ) {
+        if (i >= 0) {
 #ifdef Q_OS_WIN
             m_values.insert(s.left(i).toUpper(), s.mid(i+1));
 #else
@@ -196,13 +195,13 @@ QString Environment::searchInPath(QString executable)
         executable.append(QLatin1String(".exe"));
 #endif
     const QChar slash = QLatin1Char('/');
-    foreach(const QString &p, path()) {
+    foreach (const QString &p, path()) {
 //        qDebug()<<"trying"<<path + '/' + executable;
         QString fp = p;
         fp += slash;
         fp += executable;
         const QFileInfo fi(fp);
-        if(fi.exists()) {
+        if (fi.exists()) {
 //            qDebug()<<"returning "<<fi.absoluteFilePath();
             return fi.absoluteFilePath();
         }
@@ -248,7 +247,7 @@ Environment::const_iterator Environment::constEnd() const
 Environment::const_iterator Environment::find(const QString &name)
 {
     QMap<QString, QString>::const_iterator it = m_values.constFind(name);
-    if(it == m_values.constEnd())
+    if (it == m_values.constEnd())
         return constEnd();
     else
         return it;
@@ -263,24 +262,24 @@ void Environment::modify(const QList<EnvironmentItem> & list)
 {
     Environment resultEnvironment = *this;
     foreach (const EnvironmentItem &item, list) {
-        if(item.unset) {
+        if (item.unset) {
             resultEnvironment.unset(item.name);
         } else {
             // TODO use variable expansion
             QString value = item.value;
-            for(int i=0; i < value.size(); ++i) {
-                if(value.at(i) == QLatin1Char('$')) {
-                    if((i + 1) < value.size()) {
+            for (int i=0; i < value.size(); ++i) {
+                if (value.at(i) == QLatin1Char('$')) {
+                    if ((i + 1) < value.size()) {
                         const QChar &c = value.at(i+1);
                         int end = -1;
                         if (c == '(')
                             end = value.indexOf(')', i);
-                        else if (c=='{')
+                        else if (c == '{')
                             end = value.indexOf('}', i);
-                        if(end != -1) {
+                        if (end != -1) {
                             const QString &name = value.mid(i+2, end-i-2);
                             Environment::const_iterator it = find(name);
-                            if(it != constEnd())
+                            if (it != constEnd())
                                 value.replace(i, end-i+1, it.value());
                         }
                     }
@@ -334,7 +333,7 @@ QStringList Environment::parseCombinedArgString(const QString &program)
 QString Environment::joinArgumentList(const QStringList &arguments)
 {
     QString result;
-    foreach(QString arg, arguments) {
+    foreach (QString arg, arguments) {
         if (!result.isEmpty())
             result += QLatin1Char(' ');
         arg.replace(QLatin1String("\""), QLatin1String("\"\"\""));
diff --git a/src/plugins/projectexplorer/environmenteditmodel.cpp b/src/plugins/projectexplorer/environmenteditmodel.cpp
index 2405d86998e3760105706d734ecc84613202163c..68bb6f5fdfb9dac423cfda37ca757c67576d9a25 100644
--- a/src/plugins/projectexplorer/environmenteditmodel.cpp
+++ b/src/plugins/projectexplorer/environmenteditmodel.cpp
@@ -38,11 +38,13 @@ using namespace ProjectExplorer;
 EnvironmentModel::EnvironmentModel()
     : m_mergedEnvironments(false)
 {}
-EnvironmentModel::~EnvironmentModel() {}
+
+EnvironmentModel::~EnvironmentModel()
+{}
 
 QString EnvironmentModel::indexToVariable(const QModelIndex &index) const
 {
-    if(m_mergedEnvironments)
+    if (m_mergedEnvironments)
         return m_resultEnvironment.key(m_resultEnvironment.constBegin() + index.row());
     else
         return m_items.at(index.row()).name;
@@ -53,7 +55,7 @@ void EnvironmentModel::updateResultEnvironment()
     m_resultEnvironment = m_baseEnvironment;
     m_resultEnvironment.modify(m_items);
     foreach (const EnvironmentItem &item, m_items) {
-        if(item.unset) {
+        if (item.unset) {
             m_resultEnvironment.set(item.name, "<UNSET>");
         }
     }
@@ -68,10 +70,10 @@ void EnvironmentModel::setBaseEnvironment(const ProjectExplorer::Environment &en
 
 void EnvironmentModel::setMergedEnvironments(bool b)
 {
-    if(m_mergedEnvironments == b)
+    if (m_mergedEnvironments == b)
         return;
     m_mergedEnvironments = b;
-    if(b)
+    if (b)
         updateResultEnvironment();
     reset();
 }
@@ -96,48 +98,46 @@ int EnvironmentModel::columnCount(const QModelIndex &parent) const
 
 bool EnvironmentModel::changes(const QString &name) const
 {
-    foreach(const EnvironmentItem& item, m_items) {
-        if(item.name == name) {
+    foreach (const EnvironmentItem& item, m_items)
+        if (item.name == name)
             return true;
-        }
-    }
     return false;
 }
 
 QVariant EnvironmentModel::data(const QModelIndex &index, int role) const
 {
-    if((role == Qt::DisplayRole || role == Qt::EditRole) && index.isValid()) {
-        if((m_mergedEnvironments && index.row() >= m_resultEnvironment.size()) ||
+    if ((role == Qt::DisplayRole || role == Qt::EditRole) && index.isValid()) {
+        if ((m_mergedEnvironments && index.row() >= m_resultEnvironment.size()) ||
            (!m_mergedEnvironments && index.row() >= m_items.count())) {
             return QVariant();
         }
 
-        if(index.column() == 0) {
-            if(m_mergedEnvironments) {
+        if (index.column() == 0) {
+            if (m_mergedEnvironments) {
                 return m_resultEnvironment.key(m_resultEnvironment.constBegin() + index.row());
             } else {
                 return m_items.at(index.row()).name;
             }
-        } else if(index.column() == 1) {
-            if(m_mergedEnvironments) {
-                if(role == Qt::EditRole) {
+        } else if (index.column() == 1) {
+            if (m_mergedEnvironments) {
+                if (role == Qt::EditRole) {
                     int pos = findInChanges(indexToVariable(index));
-                    if(pos != -1)
+                    if (pos != -1)
                         return m_items.at(pos).value;
                 }
                 return m_resultEnvironment.value(m_resultEnvironment.constBegin() + index.row());
             } else {
-                if(m_items.at(index.row()).unset)
+                if (m_items.at(index.row()).unset)
                     return "<UNSET>";
                 else
                     return m_items.at(index.row()).value;
             }
         }
     }
-    if(role == Qt::FontRole) {
-        if(m_mergedEnvironments) {
+    if (role == Qt::FontRole) {
+        if (m_mergedEnvironments) {
             // check wheter this environment variable exists in m_items
-            if(changes(m_resultEnvironment.key(m_resultEnvironment.constBegin() + index.row()))) {
+            if (changes(m_resultEnvironment.key(m_resultEnvironment.constBegin() + index.row()))) {
                 QFont f;
                 f.setBold(true);
                 return QVariant(f);
@@ -157,7 +157,7 @@ Qt::ItemFlags EnvironmentModel::flags(const QModelIndex &index) const
 
 bool EnvironmentModel::hasChildren(const QModelIndex &index) const
 {
-    if(!index.isValid())
+    if (!index.isValid())
         return true;
     else
         return false;
@@ -165,14 +165,14 @@ bool EnvironmentModel::hasChildren(const QModelIndex &index) const
 
 QVariant EnvironmentModel::headerData(int section, Qt::Orientation orientation, int role) const
 {
-    if(orientation == Qt::Vertical || role != Qt::DisplayRole)
+    if (orientation == Qt::Vertical || role != Qt::DisplayRole)
         return QVariant();
     return section == 0 ? tr("Variable") : tr("Value");
 }
 
 QModelIndex EnvironmentModel::index(int row, int column, const QModelIndex &parent) const
 {
-    if(!parent.isValid())
+    if (!parent.isValid())
         return createIndex(row, column, 0);
     return QModelIndex();
 }
@@ -188,16 +188,16 @@ QModelIndex EnvironmentModel::parent(const QModelIndex &index) const
 /// *****************
 int EnvironmentModel::findInChanges(const QString &name) const
 {
-    for(int i=0; i<m_items.size(); ++i)
-        if(m_items.at(i).name == name)
+    for (int i=0; i<m_items.size(); ++i)
+        if (m_items.at(i).name == name)
             return i;
     return -1;
 }
 
 int EnvironmentModel::findInChangesInsertPosition(const QString &name) const
 {
-    for(int i=0; i<m_items.size(); ++i)
-        if(m_items.at(i).name > name)
+    for (int i=0; i<m_items.size(); ++i)
+        if (m_items.at(i).name > name)
             return i;
     return m_items.size();
 }
@@ -206,8 +206,8 @@ int EnvironmentModel::findInResult(const QString &name) const
 {
     Environment::const_iterator it;
     int i = 0;
-    for(it = m_resultEnvironment.constBegin(); it != m_resultEnvironment.constEnd(); ++it, ++i)
-        if(m_resultEnvironment.key(it) == name)
+    for (it = m_resultEnvironment.constBegin(); it != m_resultEnvironment.constEnd(); ++it, ++i)
+        if (m_resultEnvironment.key(it) == name)
             return i;
     return -1;
 }
@@ -216,28 +216,28 @@ int EnvironmentModel::findInResultInsertPosition(const QString &name) const
 {
     Environment::const_iterator it;
     int i = 0;
-    for(it = m_resultEnvironment.constBegin(); it != m_resultEnvironment.constEnd(); ++it, ++i)
-        if(m_resultEnvironment.key(it) > name)
+    for (it = m_resultEnvironment.constBegin(); it != m_resultEnvironment.constEnd(); ++it, ++i)
+        if (m_resultEnvironment.key(it) > name)
             return i;
     return m_resultEnvironment.size();
 }
 
 bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value, int role)
 {
-    if(role == Qt::EditRole && index.isValid()) {
-        if(index.column() == 0) {
+    if (role == Qt::EditRole && index.isValid()) {
+        if (index.column() == 0) {
             //fail if a variable with the same name already exists
 #ifdef Q_OS_WIN
-            if(findInChanges(value.toString().toUpper()) != -1)
+            if (findInChanges(value.toString().toUpper()) != -1)
                 return false;
 #else
-            if(findInChanges(value.toString()) != -1)
+            if (findInChanges(value.toString()) != -1)
                 return false;
 #endif
             EnvironmentItem old("", "");
-            if(m_mergedEnvironments) {
+            if (m_mergedEnvironments) {
                 int pos = findInChanges(indexToVariable(index));
-                if(pos != -1) {
+                if (pos != -1) {
                     old = m_items.at(pos);
                 } else {
                     old.name = m_resultEnvironment.key(m_resultEnvironment.constBegin() + index.row());
@@ -252,16 +252,16 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value,
 #else
             const QString &newName = value.toString();
 #endif
-            if(changes(old.name))
+            if (changes(old.name))
                 removeVariable(old.name);
             old.name = newName;
             addVariable(old);
             return true;
-        } else if(index.column() == 1) {
-            if(m_mergedEnvironments) {
+        } else if (index.column() == 1) {
+            if (m_mergedEnvironments) {
                 const QString &name = indexToVariable(index);
                 int pos = findInChanges(name);
-                if(pos != -1) {
+                if (pos != -1) {
                     m_items[pos].value = value.toString();
                     m_items[pos].unset = false;
                     updateResultEnvironment();
@@ -287,13 +287,13 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value,
 QModelIndex EnvironmentModel::addVariable()
 {
     const QString &name = "<VARIABLE>";
-    if(m_mergedEnvironments) {
+    if (m_mergedEnvironments) {
         int i = findInResult(name);
-        if(i != -1)
+        if (i != -1)
             return index(i, 0, QModelIndex());
     } else {
         int i = findInChanges(name);
-        if(i != -1)
+        if (i != -1)
             return index(i, 0, QModelIndex());
     }
     // Don't exist, really add them
@@ -302,10 +302,10 @@ QModelIndex EnvironmentModel::addVariable()
 
 QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item)
 {
-    if(m_mergedEnvironments) {
+    if (m_mergedEnvironments) {
         bool existsInBaseEnvironment = (m_baseEnvironment.find(item.name) != m_baseEnvironment.constEnd());
         int rowInResult;
-        if(existsInBaseEnvironment)
+        if (existsInBaseEnvironment)
             rowInResult = findInResult(item.name);
         else
             rowInResult = findInResultInsertPosition(item.name);
@@ -313,7 +313,7 @@ QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item)
 
         qDebug()<<"addVariable "<<item.name<<existsInBaseEnvironment<<rowInResult<<rowInChanges;
 
-        if(existsInBaseEnvironment) {
+        if (existsInBaseEnvironment) {
             m_items.insert(rowInChanges, item);
             updateResultEnvironment();
             emit dataChanged(index(rowInResult, 0, QModelIndex()), index(rowInResult, 1, QModelIndex()));
@@ -340,11 +340,11 @@ QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item)
 
 void EnvironmentModel::removeVariable(const QString &name)
 {
-    if(m_mergedEnvironments) {
+    if (m_mergedEnvironments) {
         int rowInResult = findInResult(name);
         int rowInChanges = findInChanges(name);
         bool existsInBaseEnvironment = m_baseEnvironment.find(name) != m_baseEnvironment.constEnd();
-        if(existsInBaseEnvironment) {
+        if (existsInBaseEnvironment) {
             m_items.removeAt(rowInChanges);
             updateResultEnvironment();
             emit dataChanged(index(rowInResult, 0, QModelIndex()), index(rowInResult, 1, QModelIndex()));
@@ -368,11 +368,11 @@ void EnvironmentModel::removeVariable(const QString &name)
 
 void EnvironmentModel::unset(const QString &name)
 {
-    if(m_mergedEnvironments) {
+    if (m_mergedEnvironments) {
         int row = findInResult(name);
         // look in m_items for the variable
         int pos = findInChanges(name);
-        if(pos != -1) {
+        if (pos != -1) {
             m_items[pos].unset = true;
             updateResultEnvironment();
             emit dataChanged(index(row, 0, QModelIndex()), index(row, 1, QModelIndex()));
@@ -398,7 +398,7 @@ void EnvironmentModel::unset(const QString &name)
 bool EnvironmentModel::isUnset(const QString &name)
 {
     int pos = findInChanges(name);
-    if(pos != -1)
+    if (pos != -1)
         return m_items.at(pos).unset;
     else
         return false;
diff --git a/src/plugins/projectexplorer/outputwindow.cpp b/src/plugins/projectexplorer/outputwindow.cpp
index a2e0e206aee865dc2ebc022574aee0517700fff5..81a9f292450bdbd8f5cb95830e3a5b4ac23166d3 100644
--- a/src/plugins/projectexplorer/outputwindow.cpp
+++ b/src/plugins/projectexplorer/outputwindow.cpp
@@ -64,7 +64,7 @@ bool OutputPane::canFocus()
 
 void OutputPane::setFocus()
 {
-    if(m_tabWidget->currentWidget())
+    if (m_tabWidget->currentWidget())
         m_tabWidget->currentWidget()->setFocus();
 }
 
@@ -199,7 +199,7 @@ void OutputPane::createNewOutputWindow(RunControl *rc)
     
     // First look if we can reuse a tab
     bool found = false;
-    for(int i=0; i<m_tabWidget->count(); ++i) {
+    for (int i=0; i<m_tabWidget->count(); ++i) {
         RunControl *old = runControlForTab(i);
         if (old->runConfiguration() == rc->runConfiguration() && !old->isRunning()) {
             // Reuse this tab
diff --git a/src/plugins/projectexplorer/persistentsettings.cpp b/src/plugins/projectexplorer/persistentsettings.cpp
index 38253f3ae0d3119808a21894cb2ae2bf0f71947c..0939dc17850212cad19773140dd0e435c83d818e 100644
--- a/src/plugins/projectexplorer/persistentsettings.cpp
+++ b/src/plugins/projectexplorer/persistentsettings.cpp
@@ -152,7 +152,7 @@ void PersistentSettingsWriter::writeValue(QDomElement &ps, const QVariant &varia
         QDomElement values = ps.ownerDocument().createElement("valuelist");
         values.setAttribute("type", QVariant::typeToName(QVariant::List));
         QList<QVariant> varList = variant.toList();
-        foreach(QVariant var, varList) {
+        foreach (QVariant var, varList) {
             writeValue(values, var);
         }
         ps.appendChild(values);
diff --git a/src/plugins/projectexplorer/pluginfilefactory.cpp b/src/plugins/projectexplorer/pluginfilefactory.cpp
index a3d712ff5eed396cd5aeb38df7e93075cb352eae..723d5dbaf51f62400aa8ca0c9fb78630e2cd805e 100644
--- a/src/plugins/projectexplorer/pluginfilefactory.cpp
+++ b/src/plugins/projectexplorer/pluginfilefactory.cpp
@@ -90,7 +90,7 @@ QList<ProjectFileFactory*> ProjectFileFactory::createFactories(const Core::ICore
 
     const QString filterSeparator = QLatin1String(";;");
     filterString->clear();
-    foreach(IProjectManager *manager, projectManagers) {
+    foreach (IProjectManager *manager, projectManagers) {
         rc.push_back(new ProjectFileFactory(core, manager));
         if (!filterString->isEmpty())
             *filterString += filterSeparator;
diff --git a/src/plugins/projectexplorer/processstep.cpp b/src/plugins/projectexplorer/processstep.cpp
index 4a24efa70697d347cdf477a8fd1913f749a25c8b..f2e2a8ac5437bf937b773fbbaf24783f7940ab65 100644
--- a/src/plugins/projectexplorer/processstep.cpp
+++ b/src/plugins/projectexplorer/processstep.cpp
@@ -54,7 +54,7 @@ bool ProcessStep::init(const QString &buildConfiguration)
     setEnvironment(buildConfiguration, project()->environment(buildConfiguration));
     QVariant wd = value(buildConfiguration, "workingDirectory").toString();
     QString workingDirectory;
-    if(!wd.isValid() || wd.toString().isEmpty())
+    if (!wd.isValid() || wd.toString().isEmpty())
         workingDirectory = "$BUILDDIR";
     else
         workingDirectory = wd.toString();
@@ -161,7 +161,7 @@ QString ProcessStepConfigWidget::displayName() const
 void ProcessStepConfigWidget::workingDirBrowseButtonClicked()
 {
     QString workingDirectory = QFileDialog::getExistingDirectory(this, "Select the working directory", m_ui.workingDirectoryLineEdit->text());
-    if(workingDirectory.isEmpty())
+    if (workingDirectory.isEmpty())
         return;
     m_ui.workingDirectoryLineEdit->setText(workingDirectory);
     workingDirectoryLineEditTextEdited();
@@ -170,7 +170,7 @@ void ProcessStepConfigWidget::workingDirBrowseButtonClicked()
 void ProcessStepConfigWidget::commandBrowseButtonClicked()
 {
     QString filename = QFileDialog::getOpenFileName(this, "Select the executable");
-    if(filename.isEmpty())
+    if (filename.isEmpty())
         return;
     m_ui.commandLineEdit->setText(filename);
     commandLineEditTextEdited();
@@ -179,7 +179,7 @@ void ProcessStepConfigWidget::commandBrowseButtonClicked()
 void ProcessStepConfigWidget::init(const QString &buildConfiguration)
 {
     m_buildConfiguration = buildConfiguration;
-    if(buildConfiguration != QString::null) {
+    if (buildConfiguration != QString::null) {
         m_ui.commandLineEdit->setText(m_step->command(buildConfiguration));
 
         QString workingDirectory = m_step->value(buildConfiguration, "workingDirectory").toString();
diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp
index 8c74fe6e564c067879bbfeb2a029239649e26ede..2aaed472dd4ccdd48df707af5007f16511566f34 100644
--- a/src/plugins/projectexplorer/project.cpp
+++ b/src/plugins/projectexplorer/project.cpp
@@ -40,9 +40,10 @@
 
 #include <coreplugin/ifile.h>
 #include <extensionsystem/pluginmanager.h>
+#include <utils/qtcassert.h>
 
-#include <QtCore/QTextCodec>
 #include <QtCore/QDebug>
+#include <QtCore/QTextCodec>
 
 using namespace ProjectExplorer;
 using ExtensionSystem::PluginManager;
@@ -57,11 +58,9 @@ void Project::insertBuildStep(int position, BuildStep *step)
 {
     m_buildSteps.insert(position, step);
     // check that the step has all the configurations
-    foreach(const QString & name, buildConfigurations())
-    {
+    foreach (const QString &name, buildConfigurations())
         if (!step->getBuildConfiguration(name))
             step->addBuildConfiguration(name);
-    }
 }
 
 void Project::removeBuildStep(int position)
@@ -80,11 +79,9 @@ void Project::insertCleanStep(int position, BuildStep *step)
 {
     m_cleanSteps.insert(position, step);
     // check that the step has all the configurations
-    foreach(const QString & name, buildConfigurations())
-    {
+    foreach (const QString &name, buildConfigurations())
         if (!step->getBuildConfiguration(name))
             step->addBuildConfiguration(name);
-    }
 }
 
 void Project::removeCleanStep(int position)
@@ -100,10 +97,10 @@ void Project::addBuildConfiguration(const QString &name)
 
     m_buildConfigurationValues.push_back(new BuildConfiguration(name));
 
-    for (int i = 0; i!=m_buildSteps.size(); ++i)
+    for (int i = 0; i != m_buildSteps.size(); ++i)
         m_buildSteps.at(i)->addBuildConfiguration(name);
 
-    for (int i = 0; i!=m_cleanSteps.size(); ++i)
+    for (int i = 0; i != m_cleanSteps.size(); ++i)
         m_cleanSteps.at(i)->addBuildConfiguration(name);
 }
 
@@ -113,15 +110,15 @@ void Project::removeBuildConfiguration(const QString &name)
         return;
 
     for (int i = 0; i != m_buildConfigurationValues.size(); ++i)
-        if(m_buildConfigurationValues.at(i)->name() == name) {
+        if (m_buildConfigurationValues.at(i)->name() == name) {
             delete m_buildConfigurationValues.at(i);
             m_buildConfigurationValues.removeAt(i);
             break;
         }
 
-    for (int i = 0; i!=m_buildSteps.size(); ++i)
+    for (int i = 0; i != m_buildSteps.size(); ++i)
         m_buildSteps.at(i)->removeBuildConfiguration(name);
-    for (int i = 0; i!=m_cleanSteps.size(); ++i)
+    for (int i = 0; i != m_cleanSteps.size(); ++i)
         m_cleanSteps.at(i)->removeBuildConfiguration(name);
 
 }
@@ -132,22 +129,21 @@ void Project::copyBuildConfiguration(const QString &source, const QString &dest)
         return;
 
     for (int i = 0; i != m_buildConfigurationValues.size(); ++i)
-        if(m_buildConfigurationValues.at(i)->name() == source)
+        if (m_buildConfigurationValues.at(i)->name() == source)
             m_buildConfigurationValues.push_back(new BuildConfiguration(dest, m_buildConfigurationValues.at(i)));
 
-    for (int i = 0; i!= m_buildSteps.size(); ++i)
+    for (int i = 0; i != m_buildSteps.size(); ++i)
         m_buildSteps.at(i)->copyBuildConfiguration(source, dest);
 
-    for (int i = 0; i!= m_cleanSteps.size(); ++i)
+    for (int i = 0; i != m_cleanSteps.size(); ++i)
         m_cleanSteps.at(i)->copyBuildConfiguration(source, dest);
 }
 
 QStringList Project::buildConfigurations() const
 {
     QStringList result;
-    foreach (BuildConfiguration *bc, m_buildConfigurationValues) {
+    foreach (BuildConfiguration *bc, m_buildConfigurationValues)
         result << bc->name();
-    }
     return result;
 }
 
@@ -195,39 +191,36 @@ void Project::saveSettingsImpl(PersistentSettingsWriter &writer)
     writer.saveValue("project", m_values);
 
     //save buildsettings
-    foreach(const QString & buildConfigurationName, buildConfigurations()) {
+    foreach (const QString &buildConfigurationName, buildConfigurations()) {
         QMap<QString, QVariant> temp =
             getBuildConfiguration(buildConfigurationName)->toMap();
         writer.saveValue("buildConfiguration-" + buildConfigurationName, temp);
     }
 
     QStringList buildStepNames;
-    foreach(BuildStep * buildStep, buildSteps()) {
+    foreach (BuildStep *buildStep, buildSteps())
         buildStepNames << buildStep->name();
-    }
     writer.saveValue("buildsteps", buildStepNames);
 
     QStringList cleanStepNames;
-    foreach(BuildStep * cleanStep, cleanSteps()) {
+    foreach (BuildStep *cleanStep, cleanSteps())
         cleanStepNames << cleanStep->name();
-    }
     writer.saveValue("cleansteps", cleanStepNames);
     QStringList buildConfigurationNames = buildConfigurations();
     writer.saveValue("buildconfigurations", buildConfigurationNames );
 
     //save buildstep configuration
     int buildstepnr = 0;
-    foreach(BuildStep * buildStep, buildSteps())
-    {
+    foreach (BuildStep *buildStep, buildSteps()) {
         QMap<QString, QVariant> buildConfiguration = buildStep->valuesToMap();
         writer.saveValue("buildstep" + QString().setNum(buildstepnr), buildConfiguration);
         ++buildstepnr;
     }
 
     // save each buildstep/buildConfiguration combination
-    foreach(const QString & buildConfigurationName, buildConfigurationNames) {
+    foreach (const QString &buildConfigurationName, buildConfigurationNames) {
         buildstepnr = 0;
-        foreach(BuildStep * buildStep, buildSteps()) {
+        foreach (BuildStep *buildStep, buildSteps()) {
             QMap<QString, QVariant> temp =
                 buildStep->valuesToMap(buildConfigurationName);
             writer.saveValue("buildconfiguration-" + buildConfigurationName + "-buildstep" + QString().setNum(buildstepnr), temp);
@@ -237,17 +230,16 @@ void Project::saveSettingsImpl(PersistentSettingsWriter &writer)
 
     //save cleansteps buildconfiguration
     int cleanstepnr = 0;
-    foreach(BuildStep * cleanStep, cleanSteps())
-    {
+    foreach (BuildStep *cleanStep, cleanSteps()) {
         QMap<QString, QVariant> buildConfiguration = cleanStep->valuesToMap();
         writer.saveValue("cleanstep" + QString().setNum(cleanstepnr), buildConfiguration);
         ++cleanstepnr;
     }
 
     // save each cleanstep/buildConfiguration combination
-    foreach(const QString & buildConfigurationName, buildConfigurationNames) {
+    foreach (const QString &buildConfigurationName, buildConfigurationNames) {
         cleanstepnr = 0;
-        foreach(BuildStep * cleanStep, cleanSteps()) {
+        foreach (BuildStep *cleanStep, cleanSteps()) {
             QMap<QString, QVariant> temp = cleanStep->valuesToMap(buildConfigurationName);
             writer.saveValue("buildconfiguration-" + buildConfigurationName + "-cleanstep" + QString().setNum(cleanstepnr), temp);
             ++cleanstepnr;
@@ -279,7 +271,7 @@ void Project::restoreSettingsImpl(PersistentSettingsReader &reader)
 
     //Build Settings
     const QStringList buildConfigurationNames = reader.restoreValue("buildconfigurations").toStringList();
-    foreach(const QString & buildConfigurationName, buildConfigurationNames) {
+    foreach (const QString &buildConfigurationName, buildConfigurationNames) {
         addBuildConfiguration(buildConfigurationName);
         QMap<QString, QVariant> temp =
             reader.restoreValue("buildConfiguration-" + buildConfigurationName).toMap();
@@ -287,16 +279,16 @@ void Project::restoreSettingsImpl(PersistentSettingsReader &reader)
     }
 
     QVariant buildStepsVariant = reader.restoreValue("buildsteps");
-    if(buildStepsVariant.isValid()) {
+    if (buildStepsVariant.isValid()) {
         // restoring BuildSteps from settings
         int pos = 0;
         const QList<IBuildStepFactory *> buildStepFactories =
             ExtensionSystem::PluginManager::instance()->getObjects<IBuildStepFactory>();
         QStringList buildStepNames = buildStepsVariant.toStringList();
-        foreach(const QString & buildStepName, buildStepNames) {
-            foreach(IBuildStepFactory * factory, buildStepFactories) {
-                if(factory->canCreate(buildStepName)) {
-                    BuildStep * buildStep = factory->create(this, buildStepName);
+        foreach (const QString &buildStepName, buildStepNames) {
+            foreach (IBuildStepFactory *factory, buildStepFactories) {
+                if (factory->canCreate(buildStepName)) {
+                    BuildStep *buildStep = factory->create(this, buildStepName);
                     insertBuildStep(pos, buildStep);
                     ++pos;
                     break;
@@ -307,10 +299,10 @@ void Project::restoreSettingsImpl(PersistentSettingsReader &reader)
         QStringList cleanStepNames = reader.restoreValue("cleansteps").toStringList();
         // restoring BuildSteps from settings
         pos = 0;
-        foreach(const QString & cleanStepName, cleanStepNames) {
-            foreach(IBuildStepFactory * factory, buildStepFactories) {
-                if(factory->canCreate(cleanStepName)) {
-                    BuildStep * cleanStep = factory->create(this, cleanStepName);
+        foreach (const QString &cleanStepName, cleanStepNames) {
+            foreach (IBuildStepFactory *factory, buildStepFactories) {
+                if (factory->canCreate(cleanStepName)) {
+                    BuildStep *cleanStep = factory->create(this, cleanStepName);
                     insertCleanStep(pos, cleanStep);
                     ++pos;
                     break;
@@ -324,15 +316,15 @@ void Project::restoreSettingsImpl(PersistentSettingsReader &reader)
 
         // restore BuildSteps configuration
         int buildstepnr = 0;
-        foreach(BuildStep * buildStep, buildSteps()) {
+        foreach (BuildStep *buildStep, buildSteps()) {
             QMap<QString, QVariant> buildConfiguration = reader.restoreValue("buildstep" + QString().setNum(buildstepnr)).toMap();
             buildStep->setValuesFromMap(buildConfiguration);
             ++buildstepnr;
         }
 
-        foreach(const QString & buildConfigurationName, buildConfigurationNames) {
+        foreach (const QString &buildConfigurationName, buildConfigurationNames) {
             buildstepnr = 0;
-            foreach(BuildStep * buildStep, buildSteps()) {
+            foreach (BuildStep *buildStep, buildSteps()) {
                 //get the buildconfiguration for this build step
                 QMap<QString, QVariant> buildConfiguration =
                     reader.restoreValue("buildconfiguration-" + buildConfigurationName + "-buildstep" + QString().setNum(buildstepnr)).toMap();
@@ -343,16 +335,15 @@ void Project::restoreSettingsImpl(PersistentSettingsReader &reader)
 
         // restore CleanSteps configuration
         int cleanstepnr = 0;
-        foreach(BuildStep * cleanStep, cleanSteps())
-        {
+        foreach (BuildStep *cleanStep, cleanSteps()) {
             QMap<QString, QVariant> buildConfiguration = reader.restoreValue("cleanstep" + QString().setNum(cleanstepnr)).toMap();
             cleanStep->setValuesFromMap(buildConfiguration);
             ++cleanstepnr;
         }
 
-        foreach(const QString & buildConfigurationName, buildConfigurationNames) {
+        foreach (const QString &buildConfigurationName, buildConfigurationNames) {
             cleanstepnr = 0;
-            foreach(BuildStep * cleanStep, cleanSteps()) {
+            foreach (BuildStep *cleanStep, cleanSteps()) {
                 //get the buildconfiguration for this clean step
                 QMap<QString, QVariant> buildConfiguration =
                     reader.restoreValue("buildconfiguration-" + buildConfigurationName + "-cleanstep" + QString().setNum(cleanstepnr)).toMap();
@@ -373,7 +364,7 @@ void Project::restoreSettingsImpl(PersistentSettingsReader &reader)
         if (!typeVariant.isValid())
             break;
         const QString &type = typeVariant.toString();
-        foreach (IRunConfigurationFactory * factory, factories) {
+        foreach (IRunConfigurationFactory *factory, factories) {
             if (factory->canCreate(type)) {
                 QSharedPointer<RunConfiguration> rc = factory->create(this, type);
                 rc->restore(reader);
@@ -403,7 +394,7 @@ QVariant Project::value(const QString &name) const
 {
     QMap<QString, QVariant>::const_iterator it =
         m_values.find(name);
-    if(it != m_values.constEnd())
+    if (it != m_values.constEnd())
         return it.value();
     else
         return QVariant();
@@ -420,7 +411,7 @@ BuildConfiguration * Project::getBuildConfiguration(const QString &name) const
 void Project::setValue(const QString &buildConfiguration, const QString &name, const QVariant &value)
 {
     BuildConfiguration *bc = getBuildConfiguration(buildConfiguration);
-    Q_ASSERT(bc);
+    QTC_ASSERT(bc, return);
     bc->setValue(name, value);
 }
 
@@ -454,13 +445,13 @@ QList<QSharedPointer<RunConfiguration> > Project::runConfigurations() const
 
 void Project::addRunConfiguration(QSharedPointer<RunConfiguration> runConfiguration)
 {
-    Q_ASSERT(!m_runConfigurations.contains(runConfiguration));
+    QTC_ASSERT(!m_runConfigurations.contains(runConfiguration), return);
     m_runConfigurations.push_back(runConfiguration);
 }
 
 void Project::removeRunConfiguration(QSharedPointer<RunConfiguration> runConfiguration)
 {
-    Q_ASSERT(m_runConfigurations.contains(runConfiguration));
+    QTC_ASSERT(m_runConfigurations.contains(runConfiguration), /**/);
     m_runConfigurations.removeOne(runConfiguration);
     if (m_activeRunConfiguration == runConfiguration) {
         if (m_runConfigurations.isEmpty())
@@ -479,7 +470,7 @@ void Project::setActiveRunConfiguration(QSharedPointer<RunConfiguration> runConf
 {
     if (runConfiguration == m_activeRunConfiguration)
         return;
-    Q_ASSERT(m_runConfigurations.contains(runConfiguration) || runConfiguration == 0);
+    QTC_ASSERT(m_runConfigurations.contains(runConfiguration) || runConfiguration == 0,  return);
     m_activeRunConfiguration = runConfiguration;
     emit activeRunConfigurationChanged();
 }
@@ -497,7 +488,7 @@ QString Project::displayNameFor(const QString &buildConfiguration)
 void Project::setDisplayNameFor(const QString &buildConfiguration, const QString &displayName)
 {
     QStringList displayNames;
-    foreach(const QString &bc, buildConfigurations()) {
+    foreach (const QString &bc, buildConfigurations()) {
         if (bc != buildConfiguration)
             displayNames << displayNameFor(bc);
     }
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index f67984f0da8621d9d718d7abaeb23e9720f2e370..f9149786bea059f72c96afce478f92f3185c96f4 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -78,23 +78,24 @@
 #include <coreplugin/iversioncontrol.h>
 #include <coreplugin/vcsmanager.h>
 #include <utils/listutils.h>
+#include <utils/qtcassert.h>
 
 #include <QtCore/qplugin.h>
+#include <QtCore/QDateTime>
 #include <QtCore/QDebug>
 #include <QtCore/QSettings>
-#include <QtCore/QDateTime>
-#include <QtGui/QAction>
-#include <QtGui/QFileDialog>
-#include <QtGui/QFileSystemModel>
+
 #include <QtGui/QAction>
 #include <QtGui/QApplication>
-#include <QtGui/QMessageBox>
-#include <QtGui/QMenu>
 #include <QtGui/QContextMenuEvent>
-#include <QtGui/QToolBar>
-#include <QtGui/QMainWindow>
+#include <QtGui/QFileDialog>
+#include <QtGui/QFileSystemModel>
 #include <QtGui/QHeaderView>
 #include <QtGui/QInputDialog>
+#include <QtGui/QMainWindow>
+#include <QtGui/QMenu>
+#include <QtGui/QMessageBox>
+#include <QtGui/QToolBar>
 
 Q_DECLARE_METATYPE(QSharedPointer<ProjectExplorer::RunConfiguration>);
 Q_DECLARE_METATYPE(Core::IEditorFactory *);
@@ -734,7 +735,7 @@ void ProjectExplorerPlugin::clearSession()
 void ProjectExplorerPlugin::extensionsInitialized()
 {
     m_fileFactories = ProjectFileFactory::createFactories(m_core, &m_projectFilterString);
-    foreach(ProjectFileFactory *pf, m_fileFactories) {
+    foreach (ProjectFileFactory *pf, m_fileFactories) {
         m_profileMimeTypes += pf->mimeTypes();
         addAutoReleasedObject(pf);
     }
@@ -788,7 +789,7 @@ void ProjectExplorerPlugin::setStartupProject(Project *project)
 
     if (!project)
         project = m_currentProject;
-    Q_ASSERT(project);
+    QTC_ASSERT(project, return);
     m_session->setStartupProject(project);
     // NPE: Visually mark startup project
     updateActions();
@@ -1212,7 +1213,7 @@ QStringList ProjectExplorerPlugin::allFilesWithDependencies(Project *pro)
         qDebug() << "ProjectExplorerPlugin::allFilesWithDependencies(" << pro->file()->fileName() << ")";
 
     QStringList filesToSave;
-    foreach(Project *p, m_session->projectOrder(pro)) {
+    foreach (Project *p, m_session->projectOrder(pro)) {
         FindAllFilesVisitor filesVisitor;
         p->rootProjectNode()->accept(&filesVisitor);
         filesToSave << filesVisitor.filePaths();
@@ -1537,7 +1538,7 @@ void ProjectExplorerPlugin::updateContextMenuActions()
 
 void ProjectExplorerPlugin::addNewFile()
 {
-    Q_ASSERT(m_currentNode && m_currentNode->nodeType() == ProjectNodeType);
+    QTC_ASSERT(m_currentNode && m_currentNode->nodeType() == ProjectNodeType, return);
     const QString location = QFileInfo(m_currentNode->path()).dir().absolutePath();
     m_core->showNewItemDialog(tr("New File", "Title of dialog"),
                               Core::BaseFileWizard::findWizardsOfKind(Core::IWizard::FileWizard)
@@ -1547,7 +1548,7 @@ void ProjectExplorerPlugin::addNewFile()
 
 void ProjectExplorerPlugin::addExistingFiles()
 {
-    Q_ASSERT(m_currentNode && m_currentNode->nodeType() == ProjectNodeType);
+    QTC_ASSERT(m_currentNode && m_currentNode->nodeType() == ProjectNodeType, return);
     ProjectNode *projectNode = qobject_cast<ProjectNode*>(m_currentNode);
     const QString dir = QFileInfo(m_currentNode->path()).dir().absolutePath();
     QStringList fileNames = QFileDialog::getOpenFileNames(m_core->mainWindow(), tr("Add Existing Files"), dir);
@@ -1599,14 +1600,14 @@ void ProjectExplorerPlugin::addExistingFiles()
 
 void ProjectExplorerPlugin::openFile()
 {
-    Q_ASSERT(m_currentNode);
+    QTC_ASSERT(m_currentNode, return);
     m_core->editorManager()->openEditor(m_currentNode->path());
     m_core->editorManager()->ensureEditorManagerVisible();
 }
 
 void ProjectExplorerPlugin::removeFile()
 {
-    Q_ASSERT(m_currentNode && m_currentNode->nodeType() == FileNodeType);
+    QTC_ASSERT(m_currentNode && m_currentNode->nodeType() == FileNodeType, return);
     FileNode *fileNode = qobject_cast<FileNode*>(m_currentNode);
 
     const QString filePath = m_currentNode->path();
@@ -1618,7 +1619,7 @@ void ProjectExplorerPlugin::removeFile()
 
         // remove from project
         ProjectNode *projectNode = fileNode->projectNode();
-        Q_ASSERT(projectNode);
+        QTC_ASSERT(projectNode, return);
 
         if (!projectNode->removeFiles(fileNode->fileType(), QStringList(filePath))) {
             QMessageBox::warning(m_core->mainWindow(), tr("Remove file failed"),
@@ -1770,11 +1771,11 @@ void ProjectExplorerPlugin::populateOpenWithMenu()
 
 void ProjectExplorerPlugin::openWithMenuTriggered(QAction *action)
 {
-    Q_ASSERT(action != NULL);
+    QTC_ASSERT(action, return);
     Core::IEditorFactory * const editorFactory = qVariantValue<Core::IEditorFactory *>(action->data());
-    Q_ASSERT(m_core != NULL);
-    Q_ASSERT(m_core->editorManager() != NULL);
-    Q_ASSERT(editorFactory != NULL);
+    QTC_ASSERT(m_core, return);
+    QTC_ASSERT(m_core->editorManager(), return);
+    QTC_ASSERT(editorFactory, return);
     m_core->editorManager()->openEditor(currentNode()->path(), editorFactory->kind());
     m_core->editorManager()->ensureEditorManagerVisible();
 }
@@ -1783,7 +1784,7 @@ void ProjectExplorerPlugin::updateSessionMenu()
 {
     m_sessionMenu->clear();
     const QString &activeSession = m_session->activeSession();
-    foreach(const QString &session, m_session->sessions()) {
+    foreach (const QString &session, m_session->sessions()) {
         QAction *act = m_sessionMenu->addAction(session, this, SLOT(setSession()));
         act->setCheckable(true);
         if (session == activeSession)
diff --git a/src/plugins/projectexplorer/projectmodels.cpp b/src/plugins/projectexplorer/projectmodels.cpp
index 3e04069408c1b8e6d2aa9212093322a87ac541a4..e5a2e7026508cad620caa7cfb81af625a137f3ff 100644
--- a/src/plugins/projectexplorer/projectmodels.cpp
+++ b/src/plugins/projectexplorer/projectmodels.cpp
@@ -31,19 +31,22 @@
 **
 ***************************************************************************/
 
-#include "project.h"
 #include "projectmodels.h"
+
+#include "project.h"
 #include "projectexplorerconstants.h"
 
 #include <coreplugin/fileiconprovider.h>
+#include <utils/qtcassert.h>
+
+#include <QtCore/QDebug>
+#include <QtCore/QFileInfo>
 
 #include <QtGui/QApplication>
 #include <QtGui/QIcon>
-#include <QtGui/QStyle>
 #include <QtGui/QMessageBox>
 #include <QtGui/QSortFilterProxyModel>
-#include <QtCore/QFileInfo>
-#include <QtCore/QDebug>
+#include <QtGui/QStyle>
 
 using namespace ProjectExplorer;
 using namespace ProjectExplorer::Internal;
@@ -173,7 +176,7 @@ QModelIndex DetailedModel::index(int row, int column, const QModelIndex &parent)
         result = createIndex(0, 0, m_rootNode);
     } else if (column == 0) {
         FolderNode *parentNode = qobject_cast<FolderNode*>(nodeForIndex(parent));
-        Q_ASSERT(parentNode);
+        QTC_ASSERT(parentNode, return result);
         result = createIndex(row, 0, m_childNodes.value(parentNode).at(row));
     }
     return result;
@@ -186,7 +189,7 @@ QModelIndex DetailedModel::parent(const QModelIndex &index) const
     if (Node *node = nodeForIndex(index)) {
         if (FolderNode *parentFolderNode = node->parentFolderNode()) {
             if (FolderNode *grandParentFolderNode = parentFolderNode->parentFolderNode()) {
-                Q_ASSERT(m_childNodes.contains(grandParentFolderNode));
+                QTC_ASSERT(m_childNodes.contains(grandParentFolderNode), return parentIndex);
                 int row = m_childNodes.value(grandParentFolderNode).indexOf(parentFolderNode);
                 parentIndex = createIndex(row, 0, parentFolderNode);
             } else {
@@ -348,8 +351,8 @@ bool DetailedModel::canFetchMore(const QModelIndex & parent) const
 void DetailedModel::fetchMore(const QModelIndex & parent)
 {
     FolderNode *folderNode = qobject_cast<FolderNode*>(nodeForIndex(parent));
-    Q_ASSERT(folderNode);
-    Q_ASSERT(!m_childNodes.contains(folderNode));
+    QTC_ASSERT(folderNode, return);
+    QTC_ASSERT(!m_childNodes.contains(folderNode), return);
 
     m_childNodes.insert(folderNode, childNodeList(folderNode));
 }
@@ -365,7 +368,7 @@ void DetailedModel::foldersAboutToBeAdded(FolderNode *parentFolder,
                            const QList<FolderNode*> &newFolders)
 {
     Q_UNUSED(newFolders);
-    Q_ASSERT(parentFolder);
+    QTC_ASSERT(parentFolder, return);
 
     if (m_childNodes.contains(parentFolder))
         m_folderToAddTo = parentFolder;
@@ -383,7 +386,7 @@ void DetailedModel::foldersAdded()
 void DetailedModel::foldersAboutToBeRemoved(FolderNode *parentFolder,
                            const QList<FolderNode*> &staleFolders)
 {
-    Q_ASSERT(parentFolder);
+    QTC_ASSERT(parentFolder, return);
 
     if (m_childNodes.contains(parentFolder)) {
         QList<Node*> newChildNodes = m_childNodes.value(parentFolder);
@@ -413,7 +416,7 @@ void DetailedModel::filesAboutToBeAdded(FolderNode *parentFolder,
                            const QList<FileNode*> &newFiles)
 {
     Q_UNUSED(newFiles);
-    Q_ASSERT(parentFolder);
+    QTC_ASSERT(parentFolder, return);
 
     if (m_childNodes.contains(parentFolder))
         m_folderToAddTo = parentFolder;
@@ -431,7 +434,7 @@ void DetailedModel::filesAdded()
 void DetailedModel::filesAboutToBeRemoved(FolderNode *parentFolder,
                            const QList<FileNode*> &staleFiles)
 {
-    Q_ASSERT(parentFolder);
+    QTC_ASSERT(parentFolder, return);
 
     if (m_childNodes.contains(parentFolder)) {
         QList<Node*> newChildNodes = m_childNodes.value(parentFolder);
@@ -470,7 +473,7 @@ QModelIndex DetailedModel::indexForNode(const Node *node)
         // update internal cache
         if (canFetchMore(parentIndex))
             fetchMore(parentIndex);
-        Q_ASSERT(m_childNodes.contains(parentFolder));
+        QTC_ASSERT(m_childNodes.contains(parentFolder), return QModelIndex());
 
         int row = m_childNodes.value(parentFolder).indexOf(const_cast<Node*>(node));
         if (row >= 0)
@@ -503,7 +506,7 @@ void DetailedModel::addToChildNodes(FolderNode *parentFolder, QList<Node*> newCh
 {
     QList<Node*> childNodes = m_childNodes.value(parentFolder);
     QModelIndex parentIndex = indexForNode(parentFolder);
-    Q_ASSERT(parentIndex.isValid());
+    QTC_ASSERT(parentIndex.isValid(), return);
 
     // position -> nodes, with positions in decreasing order
     QList<QPair<int, QList<Node*> > > insertions;
@@ -547,14 +550,14 @@ void DetailedModel::addToChildNodes(FolderNode *parentFolder, QList<Node*> newCh
         endInsertRows();
     }
 
-    Q_ASSERT(childNodes == newChildNodes);
+    QTC_ASSERT(childNodes == newChildNodes, /**/);
 }
 
 void DetailedModel::removeFromChildNodes(FolderNode *parentFolder, QList<Node*> newChildNodes)
 {
     QList<Node*> childNodes = m_childNodes.value(parentFolder);
     QModelIndex parentIndex = indexForNode(parentFolder);
-    Q_ASSERT(parentIndex.isValid());
+    QTC_ASSERT(parentIndex.isValid(), return);
 
     // position -> nodes, with positions in decreasing order
     QList<QPair<int, QList<Node*> > > deletions;
@@ -597,7 +600,7 @@ void DetailedModel::removeFromChildNodes(FolderNode *parentFolder, QList<Node*>
         endRemoveRows();
     }
 
-    Q_ASSERT(childNodes == newChildNodes);
+    QTC_ASSERT(childNodes == newChildNodes, /**/);
 }
 
 QList<FolderNode*> DetailedModel::recursiveSubFolders(FolderNode *parentFolder)
@@ -660,7 +663,7 @@ QModelIndex FlatModel::index(int row, int column, const QModelIndex &parent) con
         result = createIndex(0, 0, m_rootNode);
     } else if (parent.isValid() && column == 0) {
         FolderNode *parentNode = qobject_cast<FolderNode*>(nodeForIndex(parent));
-        Q_ASSERT(parentNode);
+        QTC_ASSERT(parentNode, return QModelIndex());
         QHash<FolderNode*, QList<Node*> >::const_iterator it = m_childNodes.constFind(parentNode);
         if (it == m_childNodes.constEnd()) {
             fetchMore(parentNode);
@@ -687,9 +690,9 @@ QModelIndex FlatModel::parent(const QModelIndex &idx) const
                     fetchMore(grandParentNode);
                     it = m_childNodes.constFind(grandParentNode);
                 }
-                Q_ASSERT(it != m_childNodes.constEnd());
+                QTC_ASSERT(it != m_childNodes.constEnd(), return QModelIndex());
                 const int row = it.value().indexOf(parentNode);
-                Q_ASSERT(row >= 0);
+                QTC_ASSERT(row >= 0, return QModelIndex());
                 parentIndex = createIndex(row, 0, parentNode);
             } else {
                 // top level node, parent is session
@@ -847,8 +850,8 @@ QList<Node*> FlatModel::childNodes(FolderNode *parentNode, const QSet<Node*> &bl
 
 void FlatModel::fetchMore(FolderNode *folderNode) const
 {
-    Q_ASSERT(folderNode);
-    Q_ASSERT(!m_childNodes.contains(folderNode));
+    QTC_ASSERT(folderNode, return);
+    QTC_ASSERT(!m_childNodes.contains(folderNode), return);
 
     QList<Node*> nodeList = childNodes(folderNode);
     m_childNodes.insert(folderNode, nodeList);
@@ -857,7 +860,7 @@ void FlatModel::fetchMore(FolderNode *folderNode) const
 void FlatModel::fetchMore(const QModelIndex &parent)
 {
     FolderNode *folderNode = qobject_cast<FolderNode*>(nodeForIndex(parent));
-    Q_ASSERT(folderNode);
+    QTC_ASSERT(folderNode, return);
 
     fetchMore(folderNode);
 }
@@ -988,10 +991,9 @@ void FlatModel::added(FolderNode* parentNode, const QList<Node*> &newNodeList)
         return;
     }
 
-    while(true)
-    {
+    while (true) {
         // Skip all that are the same
-        while(*oldIter == *newIter) {
+        while (*oldIter == *newIter) {
             ++oldIter;
             ++newIter;
             if (oldIter == oldNodeList.constEnd()) {
@@ -1002,7 +1004,7 @@ void FlatModel::added(FolderNode* parentNode, const QList<Node*> &newNodeList)
                 int count = newIter - startOfBlock;
                 if (count > 0) {
                     beginInsertRows(parentIndex, pos, pos+count-1);
-                    while(startOfBlock != newIter) {
+                    while (startOfBlock != newIter) {
                         oldNodeList.insert(pos, *startOfBlock);
                         ++pos;
                         ++startOfBlock;
@@ -1015,7 +1017,7 @@ void FlatModel::added(FolderNode* parentNode, const QList<Node*> &newNodeList)
         }
 
         QList<Node *>::const_iterator startOfBlock = newIter;
-        while(*oldIter != *newIter)
+        while (*oldIter != *newIter)
             ++newIter;
         // startOfBlock is the first that was diffrent
         // newIter points to the new position of oldIter
@@ -1024,7 +1026,7 @@ void FlatModel::added(FolderNode* parentNode, const QList<Node*> &newNodeList)
         int pos = oldIter - oldNodeList.constBegin();
         int count = newIter - startOfBlock;
         beginInsertRows(parentIndex, pos, pos + count - 1);
-        while(startOfBlock != newIter) {
+        while (startOfBlock != newIter) {
             oldNodeList.insert(pos, *startOfBlock);
             ++pos;
             ++startOfBlock;
@@ -1059,10 +1061,9 @@ void FlatModel::removed(FolderNode* parentNode, const QList<Node*> &newNodeList)
         return;
     }
 
-    while(true)
-    {
+    while (true) {
         // Skip all that are the same
-        while(*oldIter == *newIter) {
+        while (*oldIter == *newIter) {
             ++oldIter;
             ++newIter;
             if (newIter == newNodeList.constEnd()) {
@@ -1073,7 +1074,7 @@ void FlatModel::removed(FolderNode* parentNode, const QList<Node*> &newNodeList)
                 int count = oldIter - startOfBlock;
                 if (count > 0) {
                     beginRemoveRows(parentIndex, pos, pos+count-1);
-                    while(startOfBlock != oldIter) {
+                    while (startOfBlock != oldIter) {
                         ++startOfBlock;
                         oldNodeList.removeAt(pos);
                     }
@@ -1086,7 +1087,7 @@ void FlatModel::removed(FolderNode* parentNode, const QList<Node*> &newNodeList)
         }
 
         QList<Node *>::const_iterator startOfBlock = oldIter;
-        while(*oldIter != *newIter)
+        while (*oldIter != *newIter)
             ++oldIter;
         // startOfBlock is the first that was diffrent
         // oldIter points to the new position of newIter
@@ -1095,7 +1096,7 @@ void FlatModel::removed(FolderNode* parentNode, const QList<Node*> &newNodeList)
         int pos = startOfBlock - oldNodeList.constBegin();
         int count = oldIter - startOfBlock;
         beginRemoveRows(parentIndex, pos, pos + count - 1);
-        while(startOfBlock != oldIter) {
+        while (startOfBlock != oldIter) {
             ++startOfBlock;
             oldNodeList.removeAt(pos);
         }
@@ -1125,7 +1126,7 @@ void FlatModel::foldersAdded()
 void FlatModel::foldersAboutToBeRemoved(FolderNode *parentFolder, const QList<FolderNode*> &staleFolders)
 {
     QSet<Node *> blackList;
-    foreach(FolderNode * node, staleFolders)
+    foreach (FolderNode *node, staleFolders)
         blackList.insert(node);
 
     FolderNode *folderNode = visibleFolderNode(parentFolder);
@@ -1137,7 +1138,7 @@ void FlatModel::foldersAboutToBeRemoved(FolderNode *parentFolder, const QList<Fo
 
 void FlatModel::removeFromCache(QList<FolderNode *> list)
 {
-    foreach(FolderNode * fn, list) {
+    foreach (FolderNode *fn, list) {
         removeFromCache(fn->subFolderNodes());
         m_childNodes.remove(fn);
     }
@@ -1170,7 +1171,7 @@ void FlatModel::filesAboutToBeRemoved(FolderNode *folder, const QList<FileNode*>
     FolderNode *folderNode = visibleFolderNode(folder);
 
     QSet<Node *> blackList;
-    foreach(Node* node, staleFiles)
+    foreach(Node *node, staleFiles)
         blackList.insert(node);
 
     // Now get the new List for that folder
diff --git a/src/plugins/projectexplorer/projectnodes.cpp b/src/plugins/projectexplorer/projectnodes.cpp
index bf6174a4a36a1b3c4a92247fd55afe2ea06a52b1..7c85aae6ae36a04e85c350bbb0c4dfbf2754d297 100644
--- a/src/plugins/projectexplorer/projectnodes.cpp
+++ b/src/plugins/projectexplorer/projectnodes.cpp
@@ -31,11 +31,13 @@
 **
 ***************************************************************************/
 
-#include "nodesvisitor.h"
 #include "projectnodes.h"
+
+#include "nodesvisitor.h"
 #include "projectexplorerconstants.h"
 
 #include <coreplugin/mimedatabase.h>
+#include <utils/qtcassert.h>
 
 #include <QtCore/QFileInfo>
 #include <QtGui/QApplication>
@@ -312,8 +314,8 @@ void ProjectNode::addProjectNodes(const QList<ProjectNode*> &subProjects)
             emit watcher->foldersAboutToBeAdded(this, folderNodes);
 
         foreach (ProjectNode *project, subProjects) {
-            Q_ASSERT_X(!project->parentFolderNode(), "addProjectNodes",
-                       "Project node has already a parent");
+            QTC_ASSERT(!project->parentFolderNode(),
+                qDebug("Project node has already a parent"));
             project->setParentFolderNode(this);
             foreach (NodesWatcher *watcher, m_watchers)
                 project->registerWatcher(watcher);
@@ -351,13 +353,13 @@ void ProjectNode::removeProjectNodes(const QList<ProjectNode*> &subProjects)
         for (; toRemoveIter != toRemove.constEnd(); ++toRemoveIter) {
             while ((*projectIter)->path() != (*toRemoveIter)->path()) {
                 ++projectIter;
-                Q_ASSERT_X(projectIter != m_subProjectNodes.end(), "removeProjectNodes",
-                           "Project to remove is not part of specified folder!");
+                QTC_ASSERT(projectIter != m_subProjectNodes.end(),
+                    qDebug("Project to remove is not part of specified folder!"));
             }
             while ((*folderIter)->path() != (*toRemoveIter)->path()) {
                 ++folderIter;
-                Q_ASSERT_X(folderIter != m_subFolderNodes.end(), "removeProjectNodes",
-                           "Project to remove is not part of specified folder!");
+                QTC_ASSERT(folderIter != m_subFolderNodes.end(),
+                    qDebug("Project to remove is not part of specified folder!"));
             }
             delete *projectIter;
             projectIter = m_subProjectNodes.erase(projectIter);
@@ -374,7 +376,7 @@ void ProjectNode::removeProjectNodes(const QList<ProjectNode*> &subProjects)
   */
 void ProjectNode::addFolderNodes(const QList<FolderNode*> &subFolders, FolderNode *parentFolder)
 {
-    Q_ASSERT(parentFolder);
+    QTC_ASSERT(parentFolder, return);
 
     if (!subFolders.isEmpty()) {
         const bool emitSignals = (parentFolder->projectNode() == this);
@@ -384,15 +386,15 @@ void ProjectNode::addFolderNodes(const QList<FolderNode*> &subFolders, FolderNod
                 watcher->foldersAboutToBeAdded(parentFolder, subFolders);
 
         foreach (FolderNode *folder, subFolders) {
-            Q_ASSERT_X(!folder->parentFolderNode(), "addFolderNodes",
-                       "Project node has already a parent folder");
+            QTC_ASSERT(!folder->parentFolderNode(),
+                qDebug("Project node has already a parent folder"));
             folder->setParentFolderNode(parentFolder);
             folder->setProjectNode(this);
             parentFolder->m_subFolderNodes.append(folder);
 
             // project nodes have to be added via addProjectNodes
-            Q_ASSERT_X(folder->nodeType() != ProjectNodeType, "addFolderNodes",
-                       "project nodes have to be added via addProjectNodes");
+            QTC_ASSERT(folder->nodeType() != ProjectNodeType,
+                qDebug("project nodes have to be added via addProjectNodes"));
         }
         qSort(parentFolder->m_subFolderNodes.begin(), parentFolder->m_subFolderNodes.end(),
               sortNodesByPath);
@@ -410,7 +412,7 @@ void ProjectNode::addFolderNodes(const QList<FolderNode*> &subFolders, FolderNod
 void ProjectNode::removeFolderNodes(const QList<FolderNode*> &subFolders,
                                    FolderNode *parentFolder)
 {
-    Q_ASSERT(parentFolder);
+    QTC_ASSERT(parentFolder, return);
 
     if (!subFolders.isEmpty()) {
         const bool emitSignals = (parentFolder->projectNode() == this);
@@ -425,12 +427,12 @@ void ProjectNode::removeFolderNodes(const QList<FolderNode*> &subFolders,
         QList<FolderNode*>::const_iterator toRemoveIter = toRemove.constBegin();
         QList<FolderNode*>::iterator folderIter = parentFolder->m_subFolderNodes.begin();
         for (; toRemoveIter != toRemove.constEnd(); ++toRemoveIter) {
-            Q_ASSERT_X(((*toRemoveIter)->nodeType() != ProjectNodeType), "removeFolderNodes",
-                           "project nodes have to be removed via removeProjectNodes");
+            QTC_ASSERT((*toRemoveIter)->nodeType() != ProjectNodeType,
+                qDebug("project nodes have to be removed via removeProjectNodes"));
             while ((*folderIter)->path() != (*toRemoveIter)->path()) {
                 ++folderIter;
-                Q_ASSERT_X(folderIter != parentFolder->m_subFolderNodes.end(), "removeFileNodes",
-                           "Folder to remove is not part of specified folder!");
+                QTC_ASSERT(folderIter != parentFolder->m_subFolderNodes.end(),
+                    qDebug("Folder to remove is not part of specified folder!"));
             }
             delete *folderIter;
             folderIter = parentFolder->m_subFolderNodes.erase(folderIter);
@@ -448,7 +450,7 @@ void ProjectNode::removeFolderNodes(const QList<FolderNode*> &subFolders,
   */
 void ProjectNode::addFileNodes(const QList<FileNode*> &files, FolderNode *folder)
 {
-    Q_ASSERT(folder);
+    QTC_ASSERT(folder, return);
 
     if (!files.isEmpty()) {
         const bool emitSignals = (folder->projectNode() == this);
@@ -458,8 +460,8 @@ void ProjectNode::addFileNodes(const QList<FileNode*> &files, FolderNode *folder
                 emit watcher->filesAboutToBeAdded(folder, files);
 
         foreach (FileNode *file, files) {
-            Q_ASSERT_X(!file->parentFolderNode(), "addFileNodes",
-                       "File node has already a parent folder");
+            QTC_ASSERT(!file->parentFolderNode(),
+                qDebug("File node has already a parent folder"));
 
             file->setParentFolderNode(folder);
             file->setProjectNode(this);
@@ -480,7 +482,7 @@ void ProjectNode::addFileNodes(const QList<FileNode*> &files, FolderNode *folder
   */
 void ProjectNode::removeFileNodes(const QList<FileNode*> &files, FolderNode *folder)
 {
-    Q_ASSERT(folder);
+    QTC_ASSERT(folder, return);
 
     if (!files.isEmpty()) {
         const bool emitSignals = (folder->projectNode() == this);
@@ -497,8 +499,8 @@ void ProjectNode::removeFileNodes(const QList<FileNode*> &files, FolderNode *fol
         for (; toRemoveIter != toRemove.constEnd(); ++toRemoveIter) {
             while ((*filesIter)->path() != (*toRemoveIter)->path()) {
                 ++filesIter;
-                Q_ASSERT_X(filesIter != folder->m_fileNodes.end(), "removeFileNodes",
-                           "File to remove is not part of specified folder!");
+                QTC_ASSERT(filesIter != folder->m_fileNodes.end(),
+                    qDebug("File to remove is not part of specified folder!"));
             }
             delete *filesIter;
             filesIter = folder->m_fileNodes.erase(filesIter);
@@ -589,8 +591,8 @@ void SessionNode::addProjectNodes(const QList<ProjectNode*> &projectNodes)
             emit watcher->foldersAboutToBeAdded(this, folderNodes);
 
         foreach (ProjectNode *project, projectNodes) {
-            Q_ASSERT_X(!project->parentFolderNode(), "addProjectNodes",
-                       "Project node has already a parent folder");
+            QTC_ASSERT(!project->parentFolderNode(),
+                qDebug("Project node has already a parent folder"));
             project->setParentFolderNode(this);
             foreach (NodesWatcher *watcher, m_watchers)
                 project->registerWatcher(watcher);
@@ -619,13 +621,13 @@ void SessionNode::removeProjectNodes(const QList<ProjectNode*> &projectNodes)
         for (; toRemoveIter != toRemove.constEnd(); ++toRemoveIter) {
             while ((*projectIter)->path() != (*toRemoveIter)->path()) {
                 ++projectIter;
-                Q_ASSERT_X(projectIter != m_projectNodes.end(), "removeProjectNodes",
-                           "Project to remove is not part of specified folder!");
+                QTC_ASSERT(projectIter != m_projectNodes.end(),
+                    qDebug("Project to remove is not part of specified folder!"));
             }
             while ((*folderIter)->path() != (*toRemoveIter)->path()) {
                 ++folderIter;
-                Q_ASSERT_X(folderIter != m_subFolderNodes.end(), "removeProjectNodes",
-                           "Project to remove is not part of specified folder!");
+                QTC_ASSERT(folderIter != m_subFolderNodes.end(),
+                    qDebug("Project to remove is not part of specified folder!"));
             }
             projectIter = m_projectNodes.erase(projectIter);
             folderIter = m_subFolderNodes.erase(folderIter);
diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp
index 50882e67d9e0781fa3e40e3beea6b0cbbcf4b30d..6285bb81dee49a304e10cbd99f75607eeef22758 100644
--- a/src/plugins/projectexplorer/projecttreewidget.cpp
+++ b/src/plugins/projectexplorer/projecttreewidget.cpp
@@ -32,18 +32,21 @@
 ***************************************************************************/
 
 #include "projecttreewidget.h"
+
 #include "projectexplorer.h"
 #include "projectexplorerconstants.h"
 #include "projectmodels.h"
 
 #include <coreplugin/icore.h>
 #include <coreplugin/editormanager/editormanager.h>
+#include <utils/qtcassert.h>
+
+#include <QtCore/QDebug>
 
 #include <QtGui/QHeaderView>
 #include <QtGui/QVBoxLayout>
 #include <QtGui/QToolButton>
 #include <QtGui/QFocusEvent>
-#include <QtCore/QDebug>
 
 using namespace ProjectExplorer;
 using namespace ProjectExplorer::Internal;
@@ -208,7 +211,7 @@ void ProjectTreeWidget::setCurrentItem(Node *node, Project *project)
 void ProjectTreeWidget::handleCurrentItemChange(const QModelIndex &current)
 {
     Node *node = m_model->nodeForIndex(current);
-    Q_ASSERT(node);
+    QTC_ASSERT(node, return);
 
     bool autoSync = autoSynchronization();
     setAutoSynchronization(false);
diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp
index 38aa7f958a19f9623a223bfc58b234fe9c2ba759..c725c915c9e37692fb39507ca46d6881511714e3 100644
--- a/src/plugins/projectexplorer/projectwindow.cpp
+++ b/src/plugins/projectexplorer/projectwindow.cpp
@@ -230,13 +230,11 @@ void ProjectWindow::updateTreeWidget()
 Project *ProjectWindow::findProject(const QString &path) const
 {
     QList<Project*> projects = m_session->projects();
-    foreach(Project* project, projects) {
-        if (project->file()->fileName() == path) {
+    foreach (Project* project, projects)
+        if (project->file()->fileName() == path)
             return project;
-        }
-    }
     return 0;
- }
+}
 
 
 void ProjectWindow::handleCurrentItemChanged(QTreeWidgetItem *current)
@@ -244,7 +242,6 @@ void ProjectWindow::handleCurrentItemChanged(QTreeWidgetItem *current)
     if (current) {
         QString path = current->text(2);
         if (Project *project = findProject(path)) {
-
             m_projectExplorer->setCurrentFile(project, path);
             showProperties(project, QModelIndex());
             return;
diff --git a/src/plugins/projectexplorer/projectwizardpage.cpp b/src/plugins/projectexplorer/projectwizardpage.cpp
index 8912fbb9e948e02c1c505fd56b8ca699cb8f9aab..f7022158bc8d85ac832cb181c8963143e95e5518 100644
--- a/src/plugins/projectexplorer/projectwizardpage.cpp
+++ b/src/plugins/projectexplorer/projectwizardpage.cpp
@@ -99,7 +99,7 @@ void ProjectWizardPage::setAddToVersionControlEnabled(bool b)
 
 void ProjectWizardPage::changeEvent(QEvent *e)
 {
-    switch(e->type()) {
+    switch (e->type()) {
     case QEvent::LanguageChange:
         m_ui->retranslateUi(this);
         break;
@@ -115,7 +115,8 @@ void ProjectWizardPage::setVCSDisplay(const QString &vcsName)
 
 void ProjectWizardPage::setFilesDisplay(const QStringList &files)
 {
-    QString fileMessage; {
+    QString fileMessage;
+    {
         QTextStream str(&fileMessage);
         str << "<html>Files to be added:<pre>";
         const QStringList::const_iterator cend = files.constEnd();
diff --git a/src/plugins/projectexplorer/removefiledialog.cpp b/src/plugins/projectexplorer/removefiledialog.cpp
index 3d8f11345a237eb202929b6df79413290e3185b8..32f573b5f623e7a8c92be922e0d8c1f96147e193 100644
--- a/src/plugins/projectexplorer/removefiledialog.cpp
+++ b/src/plugins/projectexplorer/removefiledialog.cpp
@@ -59,7 +59,7 @@ bool RemoveFileDialog::isDeleteFileChecked() const
 
 void RemoveFileDialog::changeEvent(QEvent *e)
 {
-    switch(e->type()) {
+    switch (e->type()) {
     case QEvent::LanguageChange:
         m_ui->retranslateUi(this);
         break;
diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h
index 8d2e7b45d6a9a6c32b58841f0efff13e8ba65242..def848765d0bdaac89e7a83b7d33e46f94b72ba9 100644
--- a/src/plugins/projectexplorer/runconfiguration.h
+++ b/src/plugins/projectexplorer/runconfiguration.h
@@ -80,6 +80,7 @@ public:
     void setName(const QString &name);
 
     // Returns the widget used to configure this run configuration. Ownership is transferred to the caller
+    // rename to createConfigurationWidget
     virtual QWidget *configurationWidget() = 0;
 
     virtual void save(PersistentSettingsWriter &writer) const;
@@ -112,7 +113,6 @@ public:
     // used to translate the types to names to display to the user
     virtual QString nameForType(const QString &type) const = 0;
     virtual QSharedPointer<RunConfiguration> create(Project *project, const QString &type) = 0;
-    
 };
 
 class PROJECTEXPLORER_EXPORT IRunConfigurationRunner : public QObject
diff --git a/src/plugins/projectexplorer/runsettingspropertiespage.cpp b/src/plugins/projectexplorer/runsettingspropertiespage.cpp
index abbfd8c1d15b1a0e9c526d896e3b81f8eb5e9965..ce26ce4da927c91ce98b8a85b5a569319d2ef5dc 100644
--- a/src/plugins/projectexplorer/runsettingspropertiespage.cpp
+++ b/src/plugins/projectexplorer/runsettingspropertiespage.cpp
@@ -37,19 +37,22 @@
 #include "ui_runsettingspropertiespage.h"
 
 #include <extensionsystem/pluginmanager.h>
+#include <utils/qtcassert.h>
 
-#include <QDebug>
+#include <QtCore/QDebug>
 #include <QtCore/QPair>
 
 namespace ProjectExplorer {
 namespace Internal {
+
 struct FactoryAndType
 {
     ProjectExplorer::IRunConfigurationFactory *factory;
     QString type;
 };
-} // namespace
-} // namespace
+
+} // namespace Internal
+} // namespace ProjectExplorer
 
 Q_DECLARE_METATYPE(ProjectExplorer::Internal::FactoryAndType);
 
@@ -170,9 +173,9 @@ void RunConfigurationsModel::setRunConfigurations(const QList<QSharedPointer<Run
 ///
 
 RunSettingsWidget::RunSettingsWidget(Project *project)
-    : m_project(project)
-    , m_runConfigurationsModel(new RunConfigurationsModel(this))
-    , m_runConfigurationWidget(0)
+    : m_project(project),
+      m_runConfigurationsModel(new RunConfigurationsModel(this)),
+      m_runConfigurationWidget(0)
 {
     m_ui = new Ui::RunSettingsPropertiesPage;
     m_ui->setupUi(this);
@@ -214,8 +217,9 @@ RunSettingsWidget::~RunSettingsWidget()
 void RunSettingsWidget::aboutToShowAddMenu()
 {
     m_addMenu->clear();
-    QList<IRunConfigurationFactory *> factories = ExtensionSystem::PluginManager::instance()->getObjects<IRunConfigurationFactory>();
-    foreach (IRunConfigurationFactory * factory, factories) {
+    QList<IRunConfigurationFactory *> factories =
+        ExtensionSystem::PluginManager::instance()->getObjects<IRunConfigurationFactory>();
+    foreach (IRunConfigurationFactory *factory, factories) {
         QStringList types = factory->canCreate(m_project);
         foreach (const QString &type, types) {
             QAction *action = m_addMenu->addAction(factory->nameForType(type));;
@@ -243,16 +247,14 @@ void RunSettingsWidget::addRunConfiguration()
     m_project->addRunConfiguration(newRC);
     m_project->setActiveRunConfiguration(newRC);
     initRunConfigurationComboBox();
-    connect(newRC.data(), SIGNAL(nameChanged()),
-            this, SLOT(nameChanged()));
+    connect(newRC.data(), SIGNAL(nameChanged()), this, SLOT(nameChanged()));
 }
 
 void RunSettingsWidget::removeRunConfiguration()
 {
     int index = m_ui->runConfigurationCombo->currentIndex();
     QSharedPointer<RunConfiguration> rc = m_project->runConfigurations().at(index);
-    disconnect(rc.data(), SIGNAL(nameChanged()),
-               this, SLOT(nameChanged()));
+    disconnect(rc.data(), SIGNAL(nameChanged()), this, SLOT(nameChanged()));
     m_project->removeRunConfiguration(rc);
     initRunConfigurationComboBox();
 }
@@ -272,9 +274,9 @@ void RunSettingsWidget::initRunConfigurationComboBox()
 
 void RunSettingsWidget::activateRunConfiguration(int index)
 {
-    Q_ASSERT(m_project);
+    QTC_ASSERT(m_project, return);
     const QList<QSharedPointer<RunConfiguration> > runConfigurations = m_project->runConfigurations();
-    Q_ASSERT(index < runConfigurations.size());
+    QTC_ASSERT(index < runConfigurations.size(), return);
     QSharedPointer<RunConfiguration> selectedRunConfiguration = runConfigurations.at(index);
 
     // Change the active run configuration of the project
diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp
index 71057473046d4abb52f43ad766f79762ead2681a..a9bded02c61ec0ba57ef1701041f957b8afc4c8a 100644
--- a/src/plugins/projectexplorer/session.cpp
+++ b/src/plugins/projectexplorer/session.cpp
@@ -47,17 +47,20 @@
 #include <coreplugin/editormanager/ieditor.h>
 #include <coreplugin/progressmanager/progressmanagerinterface.h>
 #include <coreplugin/modemanager.h>
-#include <utils/listutils.h>
 
 #include <texteditor/itexteditor.h>
 
-#include <QtCore/QDir>
+#include <utils/listutils.h>
+#include <utils/qtcassert.h>
+
 #include <QtCore/QDebug>
+#include <QtCore/QDir>
 #include <QtCore/QFileInfo>
-#include <QtCore/QSettings>
 #include <QtCore/QFuture>
-#include <QtGui/QMessageBox>
+#include <QtCore/QSettings>
+
 #include <QtGui/QMainWindow>
+#include <QtGui/QMessageBox>
 
 namespace {
     bool debug = false;
@@ -138,21 +141,17 @@ QString SessionFile::mimeType() const
 
 bool SessionFile::load(const QString &fileName)
 {
-    Q_ASSERT(!fileName.isEmpty());
+    QTC_ASSERT(!fileName.isEmpty(), return false);
 
     if (debug)
         qDebug() << "SessionFile::load " << fileName;
 
-
-
     m_fileName = fileName;
 
     // NPE: Load the session in the background?
     // NPE: Let FileManager monitor filename
     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 
-
-
     PersistentSettingsReader reader;
     if (!reader.load(m_fileName)) {
         qWarning() << "SessionManager::load failed!" << fileName;
@@ -161,8 +160,8 @@ bool SessionFile::load(const QString &fileName)
     }
 
     m_core->progressManager()->addTask(future.future(), tr("Session"),
-                                       QLatin1String("ProjectExplorer.SessionFile.Load"),
-                                       Core::ProgressManagerInterface::CloseOnSuccess);
+       QLatin1String("ProjectExplorer.SessionFile.Load"),
+       Core::ProgressManagerInterface::CloseOnSuccess);
 
     const QStringList &keys = reader.restoreValue(QLatin1String("valueKeys")).toStringList();
     foreach (const QString &key, keys) {
@@ -184,7 +183,6 @@ bool SessionFile::load(const QString &fileName)
         }
     }
 
-
     int openEditorsCount = reader.restoreValue(QLatin1String("OpenEditors")).toInt();
 
     future.setProgressRange(0, fileList.count() + openEditorsCount + 2);
@@ -248,7 +246,7 @@ bool SessionFile::save(const QString &fileName)
     if (!fileName.isEmpty())
         m_fileName = fileName;
 
-    Q_ASSERT(!m_fileName.isEmpty());
+    QTC_ASSERT(!m_fileName.isEmpty(), return false);
 
     if (debug)
         qDebug() << "SessionFile - saving " << m_fileName;
@@ -387,10 +385,10 @@ SessionManager::SessionManager(Core::ICore *core, QObject *parent)
         dir.mkpath(configDir + "/qtcreator");
 
         // Move sessions to that directory
-        foreach(const QString &session, sessions()) {
+        foreach (const QString &session, sessions()) {
             QFile file(configDir + "/" + session + ".qws");
             if (file.exists())
-                if(file.copy(configDir + "/qtcreator/" + session + ".qws"))
+                if (file.copy(configDir + "/qtcreator/" + session + ".qws"))
                     file.remove();
         }
     }
@@ -413,15 +411,15 @@ SessionManager::~SessionManager()
 
 bool SessionManager::isDefaultVirgin() const
 {
-    return (isDefaultSession(m_sessionName)
+    return isDefaultSession(m_sessionName)
             && projects().isEmpty()
-            && m_core->editorManager()->openedEditors().isEmpty());
+            && m_core->editorManager()->openedEditors().isEmpty();
 }
 
 
 bool SessionManager::isDefaultSession(const QString &session) const
 {
-    return (session == QLatin1String("default"));
+    return session == QLatin1String("default");
 }
 
 
@@ -495,7 +493,7 @@ void SessionManager::setStartupProject(Project *startupProject)
         qDebug() << Q_FUNC_INFO << (startupProject ? startupProject->name() : "0");
 
     if (startupProject) {
-        Q_ASSERT(m_file->m_projects.contains(startupProject));
+        QTC_ASSERT(m_file->m_projects.contains(startupProject), return);
     }
 
     m_file->m_startupProject = startupProject;
@@ -568,7 +566,7 @@ void SessionManager::removeProject(Project *project)
 
 bool SessionManager::createImpl(const QString &fileName)
 {
-    Q_ASSERT(!fileName.isEmpty());
+    QTC_ASSERT(!fileName.isEmpty(), return false);
 
     if (debug)
         qDebug() << "SessionManager - creating new session " << fileName << " ...";
@@ -576,9 +574,8 @@ bool SessionManager::createImpl(const QString &fileName)
     bool success = true;
 
     if (!m_file->fileName().isEmpty()) {
-        if (!save() || !clear()) {
+        if (!save() || !clear())
             success = false;
-        }
     }
 
     if (success) {
@@ -600,7 +597,7 @@ bool SessionManager::createImpl(const QString &fileName)
 
 bool SessionManager::loadImpl(const QString &fileName)
 {
-    Q_ASSERT(!fileName.isEmpty());
+    QTC_ASSERT(!fileName.isEmpty(), return false);
 
     if (debug)
         qDebug() << "SessionManager - loading session " << fileName << " ...";
@@ -804,7 +801,7 @@ Project *SessionManager::projectForNode(Node *node) const
     while (rootProjectNode && rootProjectNode->parentFolderNode() != m_sessionNode)
         rootProjectNode = rootProjectNode->parentFolderNode();
 
-    Q_ASSERT(rootProjectNode);
+    QTC_ASSERT(rootProjectNode, return 0);
 
     QList<Project *> projectList = projects();
     foreach (Project *p, projectList) {
@@ -1082,7 +1079,7 @@ bool SessionManager::loadSession(const QString &session)
         }
     } else {
         // Create a new session with that name
-        if(!createImpl(sessionNameToFileName(session)))
+        if (!createImpl(sessionNameToFileName(session)))
             return false;
         updateName(session);
         return true;
diff --git a/src/plugins/projectexplorer/sessiondialog.cpp b/src/plugins/projectexplorer/sessiondialog.cpp
index f00697597ed32120ebbd1a5bc27df2231da55cca..b264ac11a9acafc0abb61d702e5c5721cea52922 100644
--- a/src/plugins/projectexplorer/sessiondialog.cpp
+++ b/src/plugins/projectexplorer/sessiondialog.cpp
@@ -128,7 +128,7 @@ SessionDialog::SessionDialog(SessionManager *sessionManager, const QString &last
             this, SLOT(updateActions()));
 
     QStringList sessions = sessionManager->sessions();
-    foreach(const QString &session, sessions) {
+    foreach (const QString &session, sessions) {
         m_ui.sessionList->addItem(session);
         if (session == lastSession)
             m_ui.sessionList->setCurrentRow(m_ui.sessionList->count() - 1);
diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp
index 309e8ab983693116aff611f19822792519565785..2e3131e36fc1e634be08786b62d15ec4d28a5092 100644
--- a/src/plugins/projectexplorer/taskwindow.cpp
+++ b/src/plugins/projectexplorer/taskwindow.cpp
@@ -257,7 +257,7 @@ TaskWindow::TaskWindow()
 
     m_listview->setModel(m_model);
     m_listview->setFrameStyle(QFrame::NoFrame);
-    m_listview->setWindowTitle(tr("Problems"));
+    m_listview->setWindowTitle(tr("Build Issues"));
     m_listview->setSelectionMode(QAbstractItemView::SingleSelection);
     TaskDelegate *tld = new TaskDelegate(this);
     m_listview->setItemDelegate(tld);
@@ -441,7 +441,7 @@ QSize TaskDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelInd
         int height = 0;
         QTextLayout tl(description);
         tl.beginLayout();
-        while(true) {
+        while (true) {
             QTextLine line = tl.createLine();
             if (!line.isValid())
                 break;
@@ -528,7 +528,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
         int height = 0;
         QTextLayout tl(description);
         tl.beginLayout();
-        while(true) {
+        while (true) {
             QTextLine line = tl.createLine();
             if (!line.isValid())
                 break;
diff --git a/src/plugins/projectexplorer/taskwindow.h b/src/plugins/projectexplorer/taskwindow.h
index 702534115309eb1b95c137dd9c34025faa5f42af..a3bdf47621dcccfa5bd6261a29b2e2a630d134b7 100644
--- a/src/plugins/projectexplorer/taskwindow.h
+++ b/src/plugins/projectexplorer/taskwindow.h
@@ -63,7 +63,7 @@ public:
     QWidget *outputWidget(QWidget *);
     QList<QWidget*> toolBarWidgets(void) const;
 
-    QString name() const { return tr("Problems"); }
+    QString name() const { return tr("Build Issues"); }
     int priorityInStatusBar() const;
     void clearContents();
     void visibilityChanged(bool visible);
diff --git a/src/plugins/qt4projectmanager/cesdkhandler.cpp b/src/plugins/qt4projectmanager/cesdkhandler.cpp
index cb10cba50119b97d5c4031e6a2bae56f9d6bc4af..25200c3ab2707b1ee90a05a5b3f5a40b3ab2c6a0 100644
--- a/src/plugins/qt4projectmanager/cesdkhandler.cpp
+++ b/src/plugins/qt4projectmanager/cesdkhandler.cpp
@@ -41,13 +41,13 @@ using namespace Qt4ProjectManager::Internal;
 using ProjectExplorer::Environment;
 
 CeSdkInfo::CeSdkInfo()
-    : m_major(0) , m_minor(0)
+    : m_major(0), m_minor(0)
 {
 }
 
 Environment CeSdkInfo::addToEnvironment(const Environment &env)
 {
-    qDebug()<<"adding "<<name()<< "to Environment";
+    qDebug() << "adding " << name() << "to Environment";
     Environment e(env);
     e.set("INCLUDE", m_include);
     e.set("LIB", m_lib);
@@ -66,21 +66,21 @@ QString CeSdkHandler::platformName(const QString &qtpath)
     QString CE_SDK;
     QString CE_ARCH;
     QFile f(qtpath);
-    if(f.exists() && f.open(QIODevice::ReadOnly)) {
-        while(!f.atEnd()) {
+    if (f.exists() && f.open(QIODevice::ReadOnly)) {
+        while (!f.atEnd()) {
             QByteArray line = f.readLine();
-            if(line.startsWith("CE_SDK")) {
+            if (line.startsWith("CE_SDK")) {
                 int index = line.indexOf('=');
-                if(index >= 0) {
+                if (index >= 0) {
                     CE_SDK = line.mid(index + 1).trimmed();
                 }
-            } else if(line.startsWith("CE_ARCH")) {
+            } else if (line.startsWith("CE_ARCH")) {
                 int index = line.indexOf('=');
-                if(index >= 0) {
+                if (index >= 0) {
                     CE_ARCH = line.mid(index + 1).trimmed();
                 }
             }
-            if(!CE_SDK.isEmpty() && !CE_ARCH.isEmpty()) {
+            if (!CE_SDK.isEmpty() && !CE_ARCH.isEmpty()) {
                 platformName = CE_SDK + " (" + CE_ARCH + ")";
                 break;
             }
@@ -146,9 +146,9 @@ bool CeSdkHandler::parse(const QString &vsdir)
 
 CeSdkInfo CeSdkHandler::find(const QString &name)
 {
-    qDebug()<<"looking for platform "<<name;
+    qDebug() << "looking for platform " << name;
     for (QList<CeSdkInfo>::iterator it = m_list.begin(); it != m_list.end(); ++it) {
-        qDebug()<<"...."<<it->name();
+        qDebug() << "...." << it->name();
         if (it->name() == name)
             return *it;
     }
diff --git a/src/plugins/qt4projectmanager/deployhelper.cpp b/src/plugins/qt4projectmanager/deployhelper.cpp
index 57386afd2efb4a0892a76bee97a2401fe9e7845d..cf48604ad20776df28de65adc9a173a95be40c46 100644
--- a/src/plugins/qt4projectmanager/deployhelper.cpp
+++ b/src/plugins/qt4projectmanager/deployhelper.cpp
@@ -60,9 +60,9 @@ bool DeployHelperRunStep::init(const QString &configuration)
     //find target
     m_exec = "";
     QStringList targets = QStringList(); //TODO fix m_pro->qmakeTarget();
-    foreach(const QString& target, targets) {
+    foreach (const QString &target, targets) {
         QFileInfo fi(m_appdir + QLatin1Char('/') + target);
-        if(fi.exists())
+        if (fi.exists())
             m_exec = target;
         break;
     }
diff --git a/src/plugins/qt4projectmanager/directorywatcher.cpp b/src/plugins/qt4projectmanager/directorywatcher.cpp
index 689cd0dfd036e8dadfeef940a2058ff3d9e3bebc..daf478348381c889e06768a0edae9578d2904d62 100644
--- a/src/plugins/qt4projectmanager/directorywatcher.cpp
+++ b/src/plugins/qt4projectmanager/directorywatcher.cpp
@@ -203,5 +203,59 @@ void DirectoryWatcher::updateFileList(const QString &dir)
     }
 }
 
+int FileWatcher::m_objectCount = 0;
+QHash<QString,int> FileWatcher::m_fileCount;
+QFileSystemWatcher *FileWatcher::m_watcher = 0;
+
+FileWatcher::FileWatcher(QObject *parent)
+{
+    if (!m_watcher)
+        m_watcher = new QFileSystemWatcher();
+    ++m_objectCount;
+    connect(m_watcher, SIGNAL(fileChanged(QString)),
+            this, SLOT(slotFileChanged(QString)));
+}
+
+FileWatcher::~FileWatcher()
+{
+    foreach (const QString &file, m_files)
+        removeFile(file);
+    if (--m_objectCount == 0) {
+        delete m_watcher;
+        m_watcher = 0;
+    }
+}
+
+void FileWatcher::slotFileChanged(const QString &file)
+{
+    if (m_files.contains(file))
+        emit fileChanged(file);
+}
+
+QStringList FileWatcher::files()
+{
+    return m_files;
+}
+
+void FileWatcher::addFile(const QString &file)
+{
+    if (m_files.contains(file))
+        return;
+    m_files += file;
+    if (m_fileCount[file] == 0)
+        m_watcher->addPath(file);
+    m_fileCount[file] += 1;
+}
+
+void FileWatcher::removeFile(const QString &file)
+{
+    m_files.removeOne(file);
+    m_fileCount[file] -= 1;
+    if (m_fileCount[file] == 0)
+      m_watcher->removePath(file);
+}
+
+
+
 } // namespace Internal
 } // namespace Qt4ProjectManager
diff --git a/src/plugins/qt4projectmanager/directorywatcher.h b/src/plugins/qt4projectmanager/directorywatcher.h
index 3f5f5a846fa1a62484a8a5cc99ce53f9d1157c79..b529ec07e7835281c1b0d02c0974bc11d0acf944 100644
--- a/src/plugins/qt4projectmanager/directorywatcher.h
+++ b/src/plugins/qt4projectmanager/directorywatcher.h
@@ -87,6 +87,31 @@ private:
     FileModificationTimeMap m_files;
 };
 
+class FileWatcher : public QObject
+{
+    Q_DISABLE_COPY(FileWatcher)
+    Q_OBJECT
+public:
+    explicit FileWatcher(QObject *parent = 0);
+    virtual ~FileWatcher();
+
+    QStringList files();
+    void addFile(const QString &file);
+    void removeFile(const QString &file);
+signals:
+    void fileChanged(const QString &path);
+    void debugOutout(const QString &path);
+
+private slots:
+    void slotFileChanged(const QString&);
+
+private:
+    static int m_objectCount;
+    static QHash<QString, int> m_fileCount;
+    static QFileSystemWatcher *m_watcher;
+    QStringList m_files;
+};
+
 } // namespace Internal
 } // namespace Qt4ProjectManager
 
diff --git a/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp b/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp
index 0046a9e4acfcb36e0051f700dbf90d694df36e00..d7f55ba711411840213776099e4b3b376e407541 100644
--- a/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp
+++ b/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp
@@ -33,10 +33,12 @@
 
 #include "gdbmacrosbuildstep.h"
 
-#include "qt4projectmanagerconstants.h"
-#include "qt4project.h"
-#include "qmakestep.h"
 #include "makestep.h"
+#include "qmakestep.h"
+#include "qt4project.h"
+#include "qt4projectmanagerconstants.h"
+
+#include <utils/qtcassert.h>
 
 using namespace Qt4ProjectManager;
 using namespace Qt4ProjectManager::Internal;
@@ -74,7 +76,7 @@ void GdbMacrosBuildStep::run(QFutureInterface<bool> & fi)
     QString destDir = m_buildDirectory + "/qtc-gdbmacros/";
     QDir dir;
     dir.mkpath(destDir);
-    foreach(const QString &file, files) {
+    foreach (const QString &file, files) {
         QFile destination(destDir + file);
         if (destination.exists())
             destination.remove();
@@ -116,7 +118,7 @@ void GdbMacrosBuildStep::run(QFutureInterface<bool> & fi)
         QStringList makeargs = ms->value(m_buildConfiguration, "makeargs").toStringList();
         if (makeargs.contains("debug")) {
             makeArguments <<  "debug";
-        } else if(makeargs.contains("release")) {
+        } else if (makeargs.contains("release")) {
             makeArguments << "release";
         }
     }
@@ -160,9 +162,9 @@ bool GdbMacrosBuildStepFactory::canCreate(const QString &name) const
 
 ProjectExplorer::BuildStep *GdbMacrosBuildStepFactory::create(ProjectExplorer::Project *pro, const QString &name) const
 {
-    Q_ASSERT(name == Constants::GDBMACROSBUILDSTEP);
+    QTC_ASSERT(name == Constants::GDBMACROSBUILDSTEP, return 0);
     Qt4Project *qt4project = qobject_cast<Qt4Project *>(pro);
-    Q_ASSERT(qt4project);
+    QTC_ASSERT(qt4project, return 0);
     return new GdbMacrosBuildStep(qt4project);
 }
 
diff --git a/src/plugins/qt4projectmanager/makestep.cpp b/src/plugins/qt4projectmanager/makestep.cpp
index d88281ce59681fa96274350cae9b2e46f21a742a..55ef402fb970025e98674f5e62abc2ebbd5f25af 100644
--- a/src/plugins/qt4projectmanager/makestep.cpp
+++ b/src/plugins/qt4projectmanager/makestep.cpp
@@ -37,9 +37,10 @@
 #include "qt4projectmanagerconstants.h"
 
 #include <extensionsystem/ExtensionSystemInterfaces>
+#include <utils/qtcassert.h>
 
-#include <QFileInfo>
-#include <QDir>
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
 
 using ProjectExplorer::IBuildParserFactory;
 using ProjectExplorer::BuildParserInterface;
@@ -69,7 +70,7 @@ ProjectExplorer::BuildParserInterface *MakeStep::buildParser(const QtVersion * c
 {
     QString buildParser;
     QtVersion::ToolchainType type = version->toolchainType();
-    if( type == QtVersion::MSVC || type == QtVersion::WINCE)
+    if ( type == QtVersion::MSVC || type == QtVersion::WINCE)
         buildParser = Constants::BUILD_PARSER_MSVC;
     else
         buildParser = Constants::BUILD_PARSER_GCC;
@@ -92,18 +93,18 @@ bool MakeStep::init(const QString &name)
     QString workingDirectory;
     if (project()->value(name, "useShadowBuild").toBool())
         workingDirectory = project()->value(name, "buildDirectory").toString();
-    if(workingDirectory.isEmpty())
+    if (workingDirectory.isEmpty())
         workingDirectory = QFileInfo(project()->file()->fileName()).absolutePath();
     setWorkingDirectory(name, workingDirectory);
 
     //NBS only dependency on Qt4Project, we probably simply need a MakeProject from which Qt4Project derives
     QString makeCmd = qobject_cast<Qt4Project *>(project())->qtVersion(name)->makeCommand();
-    if(!value(name, "makeCmd").toString().isEmpty())
+    if (!value(name, "makeCmd").toString().isEmpty())
         makeCmd = value(name, "makeCmd").toString();
     if (!QFileInfo(makeCmd).isAbsolute()) {
         // Try to detect command in environment
         QString tmp = environment.searchInPath(makeCmd);
-        if(tmp == QString::null) {
+        if (tmp == QString::null) {
             emit addToOutputWindow(tr("<font color=\"#ff0000\">Could not find make command: %1 "\
                                       "in the build environment</font>").arg(makeCmd));
             return false;
@@ -289,10 +290,11 @@ void MakeStepConfigWidget::init(const QString &buildConfiguration)
 {
     m_buildConfiguration = buildConfiguration;
     bool showPage0 = buildConfiguration.isNull();
-    m_ui.stackedWidget->setCurrentIndex(showPage0? 0 : 1);
+    m_ui.stackedWidget->setCurrentIndex(showPage0 ? 0 : 1);
 
-    if(!showPage0) {
+    if (!showPage0) {
         Qt4Project *pro = qobject_cast<Qt4Project *>(m_makeStep->project());
+        QTC_ASSERT(pro, return);
         m_ui.makeLabel->setText(tr("Override %1:").arg(pro->qtVersion(buildConfiguration)->makeCommand()));
 
         const QString &makeCmd = m_makeStep->value(buildConfiguration, "makeCmd").toString();
@@ -307,12 +309,12 @@ void MakeStepConfigWidget::init(const QString &buildConfiguration)
 
 void MakeStepConfigWidget::makeLineEditTextEdited()
 {
-    Q_ASSERT(!m_buildConfiguration.isNull());
+    QTC_ASSERT(!m_buildConfiguration.isNull(), return);
     m_makeStep->setValue(m_buildConfiguration, "makeCmd", m_ui.makeLineEdit->text());
 }
 
 void MakeStepConfigWidget::makeArgumentsLineEditTextEdited()
 {
-    Q_ASSERT(!m_buildConfiguration.isNull());
+    QTC_ASSERT(!m_buildConfiguration.isNull(), return);
     m_makeStep->setValue(m_buildConfiguration, "makeargs", ProjectExplorer::Environment::parseCombinedArgString(m_ui.makeArgumentsLineEdit->text()));
 }
diff --git a/src/plugins/qt4projectmanager/msvcenvironment.cpp b/src/plugins/qt4projectmanager/msvcenvironment.cpp
index 1c3a158d72fc4f79d1628d9a3bdabc5f349d3602..48d751f0f2593b7f87b0e7d3a833c950f59b4b97 100644
--- a/src/plugins/qt4projectmanager/msvcenvironment.cpp
+++ b/src/plugins/qt4projectmanager/msvcenvironment.cpp
@@ -66,7 +66,7 @@ QList<MSVCEnvironment> MSVCEnvironment::availableVersions()
     QSettings registry("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7", 
                        QSettings::NativeFormat);
     QStringList versions = registry.allKeys();
-    foreach(const QString &version, versions) {
+    foreach (const QString &version, versions) {
         QString dir = registry.value(version).toString();
         result << MSVCEnvironment(version, dir);
     }
@@ -92,7 +92,7 @@ Environment MSVCEnvironment::addToEnvironment(const Environment &env) const
         QString varsbat = m_path + "Common7\\Tools\\vsvars32.bat";
         if (QFileInfo(varsbat).exists()) {
             QTemporaryFile tf(QDir::tempPath() + "\\XXXXXX.bat");
-            if(!tf.open())
+            if (!tf.open())
                 return e;
             QString filename = tf.fileName();
             tf.write("call \"" + varsbat.toLocal8Bit()+"\"\r\n");
@@ -107,13 +107,13 @@ Environment MSVCEnvironment::addToEnvironment(const Environment &env) const
             tf.close();
 
             QFile vars(QDir::tempPath() + "\\qtcreator-msvc-environment.txt");
-            if(vars.exists() && vars.open(QIODevice::ReadOnly)) {
-                while(!vars.atEnd()) {
+            if (vars.exists() && vars.open(QIODevice::ReadOnly)) {
+                while (!vars.atEnd()) {
                     QByteArray line = vars.readLine();
                     QString line2 = QString::fromLocal8Bit(line);
                     line2 = line2.trimmed();
                     QRegExp regexp("(\\w*)=(.*)");
-                    if(regexp.exactMatch(line2)) {
+                    if (regexp.exactMatch(line2)) {
                         QString variable = regexp.cap(1);
                         QString value = regexp.cap(2);
                         value.replace('%' + variable + '%', e.value(variable));
@@ -137,13 +137,13 @@ Environment MSVCEnvironment::addToEnvironment(const Environment &env) const
 
 
 //    QFile varsbat(m_path + "Common7\\Tools\\vsvars32.bat");
-//    if(varsbat.exists() && varsbat.open(QIODevice::ReadOnly)) {
-//        while(!varsbat.atEnd()) {
+//    if (varsbat.exists() && varsbat.open(QIODevice::ReadOnly)) {
+//        while (!varsbat.atEnd()) {
 //            QByteArray line = varsbat.readLine();
 //            QString line2 = QString::fromLocal8Bit(line);
 //            line2 = line2.trimmed();
 //            QRegExp regexp("\\s*@?(S|s)(E|e)(T|t)\\s*(\\w*)=(.*)");
-//            if(regexp.exactMatch(line2)) {
+//            if (regexp.exactMatch(line2)) {
 //                QString variable = regexp.cap(4);
 //                QString value = regexp.cap(5);
 //                value.replace('%' + variable + '%', e.value(variable));
diff --git a/src/plugins/qt4projectmanager/profilereader.cpp b/src/plugins/qt4projectmanager/profilereader.cpp
index 9f65cc890d0da62b194421dfc481cdc4bac07c3d..2b4c817928f385e54b8cdba0302f3282be311ecd 100644
--- a/src/plugins/qt4projectmanager/profilereader.cpp
+++ b/src/plugins/qt4projectmanager/profilereader.cpp
@@ -45,7 +45,7 @@ ProFileReader::ProFileReader()
 
 ProFileReader::~ProFileReader()
 {
-    foreach(ProFile *pf, m_proFiles)
+    foreach (ProFile *pf, m_proFiles)
         delete pf;
 }
 
diff --git a/src/plugins/qt4projectmanager/qmakestep.cpp b/src/plugins/qt4projectmanager/qmakestep.cpp
index 44780a7dcc5584ce297475f637b1a619e41235dd..85852f01885029400a47adde296f9a70f9d6a43e 100644
--- a/src/plugins/qt4projectmanager/qmakestep.cpp
+++ b/src/plugins/qt4projectmanager/qmakestep.cpp
@@ -40,6 +40,7 @@
 #include "qtversionmanager.h"
 
 #include <coreplugin/icore.h>
+#include <utils/qtcassert.h>
 
 #include <QFileDialog>
 #include <QDir>
@@ -65,7 +66,7 @@ QStringList QMakeStep::arguments(const QString &buildConfiguration)
     QStringList arguments;
     arguments << project()->file()->fileName();
     if (!additonalArguments.contains("-spec")) {
-        if(m_pro->value("useVBOX").toBool()) { //NBS TODO don't special case VBOX like this
+        if (m_pro->value("useVBOX").toBool()) { //NBS TODO don't special case VBOX like this
             arguments << "-spec" << "linux-i686fb-g++";
             arguments << "-unix";
         } else {
@@ -116,7 +117,7 @@ bool QMakeStep::init(const QString &name)
     QString workingDirectory = m_pro->buildDirectory(name);
 
     Environment environment = m_pro->environment(name);
-    if(!environment.value("QMAKESPEC").isEmpty() && environment.value("QMAKESPEC") != qtVersion->mkspec())
+    if (!environment.value("QMAKESPEC").isEmpty() && environment.value("QMAKESPEC") != qtVersion->mkspec())
         emit addToOutputWindow(tr("QMAKESPEC set to ") + environment.value("QMAKESPEC") +
                                tr(" overrides mkspec of selected qt ")+qtVersion->mkspec());
 
@@ -233,7 +234,7 @@ QMakeStepConfigWidget::QMakeStepConfigWidget(QMakeStep *step)
 
 void QMakeStepConfigWidget::qmakeArgumentsLineEditTextEdited()
 {
-    Q_ASSERT(!m_buildConfiguration.isNull());
+    QTC_ASSERT(!m_buildConfiguration.isNull(), return);
     m_step->setValue(m_buildConfiguration, "qmakeArgs", ProjectExplorer::Environment::parseCombinedArgString(m_ui.qmakeAdditonalArgumentsLineEdit->text()));
     m_ui.qmakeArgumentsEdit->setPlainText(ProjectExplorer::Environment::joinArgumentList(m_step->arguments(m_buildConfiguration)));
 }
diff --git a/src/plugins/qt4projectmanager/qt4buildconfigwidget.cpp b/src/plugins/qt4projectmanager/qt4buildconfigwidget.cpp
index a9d7753cfbbc76255e9f2415255cbdac4b5a454a..75ea55097c1fa98c20580179fb08374260c00a66 100644
--- a/src/plugins/qt4projectmanager/qt4buildconfigwidget.cpp
+++ b/src/plugins/qt4projectmanager/qt4buildconfigwidget.cpp
@@ -118,31 +118,31 @@ void Qt4BuildConfigWidget::setupQtVersionsComboBox()
     if (m_buildConfiguration.isEmpty()) // not yet initialized
         return;
 
-    disconnect(m_ui->qtVersionComboBox, SIGNAL(currentIndexChanged(const QString &)),
-        this, SLOT(qtVersionComboBoxCurrentIndexChanged(const QString &)));
+    disconnect(m_ui->qtVersionComboBox, SIGNAL(currentIndexChanged(QString)),
+        this, SLOT(qtVersionComboBoxCurrentIndexChanged(QString)));
 
     m_ui->qtVersionComboBox->clear();
     m_ui->qtVersionComboBox->addItem(tr("Default Qt Version"), 0);
 
-    if(m_pro->qtVersionId(m_buildConfiguration) == 0) {
+    if (m_pro->qtVersionId(m_buildConfiguration) == 0) {
         m_ui->qtVersionComboBox->setCurrentIndex(0);
         m_ui->invalidQtWarningLabel->setVisible(false);
     }
     // Add Qt Versions to the combo box
     QtVersionManager *vm = m_pro->qt4ProjectManager()->versionManager();
     const QList<QtVersion *> &versions = vm->versions();
-    for(int i=0; i<versions.size(); ++i) {
+    for (int i = 0; i < versions.size(); ++i) {
         m_ui->qtVersionComboBox->addItem(versions.at(i)->name(), versions.at(i)->uniqueId());
 
-        if(versions.at(i)->uniqueId() == m_pro->qtVersionId(m_buildConfiguration)) {
-            m_ui->qtVersionComboBox->setCurrentIndex(i+1);
+        if (versions.at(i)->uniqueId() == m_pro->qtVersionId(m_buildConfiguration)) {
+            m_ui->qtVersionComboBox->setCurrentIndex(i + 1);
             m_ui->invalidQtWarningLabel->setVisible(!versions.at(i)->isValid());
         }
     }
 
     // And connect again
-    connect(m_ui->qtVersionComboBox, SIGNAL(currentIndexChanged(const QString &)),
-        this, SLOT(qtVersionComboBoxCurrentIndexChanged(const QString &)));
+    connect(m_ui->qtVersionComboBox, SIGNAL(currentIndexChanged(QString)),
+        this, SLOT(qtVersionComboBoxCurrentIndexChanged(QString)));
 }
 
 void Qt4BuildConfigWidget::shadowBuildButtonClicked()
@@ -180,7 +180,7 @@ void Qt4BuildConfigWidget::shadowBuildLineEditTextChanged()
     m_ui->importLabel->setVisible(false);
     if (m_ui->shadowBuildCheckBox->isChecked()) {
         QString qtPath = m_pro->qt4ProjectManager()->versionManager()->findQtVersionFromMakefile(m_ui->shadowBuildLineEdit->text());
-        if(!qtPath.isEmpty()) {
+        if (!qtPath.isEmpty()) {
             m_ui->importLabel->setVisible(true);
         }
     }
@@ -252,7 +252,7 @@ void Qt4BuildConfigWidget::qtVersionComboBoxCurrentIndexChanged(const QString &)
     }
     bool isValid = m_pro->qt4ProjectManager()->versionManager()->version(newQtVersion)->isValid();
     m_ui->invalidQtWarningLabel->setVisible(!isValid);
-    if(newQtVersion != m_pro->qtVersionId(m_buildConfiguration)) {
+    if (newQtVersion != m_pro->qtVersionId(m_buildConfiguration)) {
         m_pro->setQtVersion(m_buildConfiguration, newQtVersion);
         m_pro->update();
     }
diff --git a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp
index 98dbd196a1d9ca8d3c6890a2d1fbbf4014112824..84ae6744a455e878f142a3694065c83a062079e4 100644
--- a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp
+++ b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp
@@ -127,7 +127,7 @@ void Qt4BuildEnvironmentWidget::removeEnvironmentButtonClicked()
 void Qt4BuildEnvironmentWidget::unsetEnvironmentButtonClicked()
 {
     const QString &name = m_environmentModel->indexToVariable(m_ui->environmentTreeView->currentIndex());
-    if(!m_environmentModel->isInBaseEnvironment(name) && m_environmentModel->mergedEnvironments())
+    if (!m_environmentModel->isInBaseEnvironment(name) && m_environmentModel->mergedEnvironments())
         m_environmentModel->removeVariable(name);
     else
         m_environmentModel->unset(name);
@@ -138,7 +138,7 @@ void Qt4BuildEnvironmentWidget::switchEnvironmentTab(int newTab)
 {
     bool mergedEnvironments = (newTab == 0);
     m_environmentModel->setMergedEnvironments(mergedEnvironments);
-    if(mergedEnvironments) {
+    if (mergedEnvironments) {
         m_ui->removeButton->setText(tr("Reset"));
     } else {
         m_ui->removeButton->setText(tr("Remove"));
@@ -153,8 +153,8 @@ void Qt4BuildEnvironmentWidget::updateButtonsEnabled()
 void Qt4BuildEnvironmentWidget::environmentCurrentIndexChanged(const QModelIndex &current, const QModelIndex &previous)
 {
     Q_UNUSED(previous)
-    if(current.isValid()) {
-        if(m_environmentModel->mergedEnvironments()) {
+    if (current.isValid()) {
+        if (m_environmentModel->mergedEnvironments()) {
             const QString &name = m_environmentModel->indexToVariable(current);
             bool modified = m_environmentModel->isInBaseEnvironment(name) && m_environmentModel->changes(name);
             bool unset = m_environmentModel->isUnset(name);
diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp
index 73e3620f9bccfbf4e6f54111a9690692be3f07b5..dc004580b2b40ea858288e5fcc8af58b48a75803 100644
--- a/src/plugins/qt4projectmanager/qt4nodes.cpp
+++ b/src/plugins/qt4projectmanager/qt4nodes.cpp
@@ -33,12 +33,12 @@
 
 #include "proeditormodel.h"
 
+#include "directorywatcher.h"
 #include "profilereader.h"
 #include "prowriter.h"
 #include "qt4nodes.h"
 #include "qt4project.h"
 #include "qt4projectmanager.h"
-#include "directorywatcher.h"
 
 #include <projectexplorer/nodesvisitor.h>
 
@@ -50,11 +50,14 @@
 
 #include <cpptools/cppmodelmanagerinterface.h>
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/QDebug>
 #include <QtCore/QDir>
 #include <QtCore/QFile>
 #include <QtCore/QFileInfo>
 #include <QtCore/QTimer>
+
 #include <QtGui/QMainWindow>
 #include <QtGui/QMessageBox>
 #include <QtGui/QPushButton>
@@ -84,17 +87,26 @@ Qt4PriFileNode::Qt4PriFileNode(Qt4Project *project, Qt4ProFileNode* qt4ProFileNo
           m_project(project),
           m_qt4ProFileNode(qt4ProFileNode),
           m_projectFilePath(QDir::fromNativeSeparators(filePath)),
-          m_projectDir(QFileInfo(filePath).absolutePath())
+          m_projectDir(QFileInfo(filePath).absolutePath()),
+          m_fileWatcher(new FileWatcher(this))
 {
-    Q_ASSERT(project);
+    QTC_ASSERT(project, return);
     setFolderName(QFileInfo(filePath).baseName());
     setIcon(QIcon(":/qt4projectmanager/images/qt_project.png"));
+    m_fileWatcher->addFile(filePath);
+    connect(m_fileWatcher, SIGNAL(fileChanged(QString)),
+            this, SLOT(scheduleUpdate()));
+}
+
+void Qt4PriFileNode::scheduleUpdate()
+{
+    m_qt4ProFileNode->scheduleUpdate();
 }
 
 void Qt4PriFileNode::update(ProFile *includeFile, ProFileReader *reader)
 {
-    Q_ASSERT(includeFile);
-    Q_ASSERT(reader);
+    QTC_ASSERT(includeFile, return);
+    QTC_ASSERT(reader, return);
 
     // add project file node
     if (m_fileNodes.isEmpty())
@@ -167,7 +179,7 @@ QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions() const
     const Qt4ProFileNode *proFileNode;
     while (!(proFileNode = qobject_cast<const Qt4ProFileNode*>(folderNode)))
         folderNode = folderNode->parentFolderNode();
-    Q_ASSERT(proFileNode);
+    QTC_ASSERT(proFileNode, return actions);
 
     switch (proFileNode->projectType()) {
     case ApplicationTemplate:
@@ -321,7 +333,7 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
     }
 
     ProFile *includeFile = reader->proFileFor(m_projectFilePath);
-    if(!includeFile) {
+    if (!includeFile) {
         m_project->proFileParseError(tr("Error while changing pro file %1.").arg(m_projectFilePath));
     }
 
@@ -418,7 +430,7 @@ void Qt4PriFileNode::save(ProFile *includeFile)
     Core::FileManager *fileManager = core->fileManager();
     QList<Core::IFile *> allFileHandles = fileManager->managedFiles(includeFile->fileName());
     Core::IFile *modifiedFileHandle = 0;
-    foreach(Core::IFile *file, allFileHandles)
+    foreach (Core::IFile *file, allFileHandles)
         if (file->fileName() == includeFile->fileName())
             modifiedFileHandle = file;
 
@@ -492,12 +504,17 @@ Qt4ProFileNode::Qt4ProFileNode(Qt4Project *project,
     if (parent)
         setParent(parent);
 
+    m_updateTimer.setInterval(100);
+    m_updateTimer.setSingleShot(true);
+
     connect(m_dirWatcher, SIGNAL(directoryChanged(const QString&)),
-            this, SLOT(update()));
+            this, SLOT(updateGeneratedFiles()));
     connect(m_dirWatcher, SIGNAL(fileChanged(const QString&)),
             this, SLOT(fileChanged(const QString&)));
     connect(m_project, SIGNAL(activeBuildConfigurationChanged()),
             this, SLOT(update()));
+    connect(&m_updateTimer, SIGNAL(timeout()),
+            this, SLOT(update()));
 }
 
 Qt4ProFileNode::~Qt4ProFileNode()
@@ -520,6 +537,11 @@ QStringList Qt4ProFileNode::variableValue(const Qt4Variable var) const
     return m_varValues.value(var);
 }
 
+void Qt4ProFileNode::scheduleUpdate()
+{
+    m_updateTimer.start();
+}
+
 void Qt4ProFileNode::update()
 {
     ProFileReader *reader = createProFileReader();
@@ -678,9 +700,11 @@ void Qt4ProFileNode::update()
 
 void Qt4ProFileNode::fileChanged(const QString &filePath)
 {
+    qDebug()<<"+++++"<<filePath;
     CppTools::CppModelManagerInterface *modelManager =
         ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
 
+    // TODO compress
     modelManager->updateSourceFiles(QStringList() << filePath);
 }
 
@@ -728,11 +752,16 @@ void Qt4ProFileNode::updateGeneratedFiles()
 
     // update generated files
 
+    // Already existing FileNodes
     QList<FileNode*> existingFileNodes;
     foreach (FileNode *file, fileNodes()) {
         if (file->isGenerated())
             existingFileNodes << file;
     }
+
+
+    // Convert uiFile to uiHeaderFilePath, find all headers that correspond
+    // and try to find them in uicDirs
     QStringList newFilePaths;
     foreach (const QString &uicDir, m_varValues[UiDirVar]) {
         foreach (FileNode *uiFile, uiFiles) {
diff --git a/src/plugins/qt4projectmanager/qt4nodes.h b/src/plugins/qt4projectmanager/qt4nodes.h
index 97bc06a08f4f264946d5f209c1a812ba5b6986f3..6b858bc52594ba4855e163c38c4637a540606d0e 100644
--- a/src/plugins/qt4projectmanager/qt4nodes.h
+++ b/src/plugins/qt4projectmanager/qt4nodes.h
@@ -75,6 +75,7 @@ using ProjectExplorer::FileType;
 
 class ProFileReader;
 class DirectoryWatcher;
+class FileWatcher;
 
 //  Type of projects
 enum Qt4ProjectType {
@@ -142,6 +143,9 @@ protected:
     QString buildDir() const;
     ProFileReader *createProFileReader() const;
 
+private slots:
+    void scheduleUpdate();
+
 private:
     void save(ProFile *includeFile);
     bool priFileWritable(const QString &path);
@@ -151,7 +155,10 @@ private:
     Qt4ProFileNode *m_qt4ProFileNode;
     QString m_projectFilePath;
     QString m_projectDir;
-    QTimer *m_saveTimer;
+
+    // TODO we might be better off using an IFile* and the FileManager for
+    // watching changes to the .pro and .pri files on disk
+    FileWatcher *m_fileWatcher;
 
     // managed by Qt4ProFileNode
     friend class Qt4ProFileNode;
@@ -174,14 +181,13 @@ public:
     QStringList variableValue(const Qt4Variable var) const;
 
 public slots:
+    void scheduleUpdate();
     void update();
-
 private slots:
     void fileChanged(const QString &filePath);
-
-private:
     void updateGeneratedFiles();
 
+private:
     Qt4ProFileNode *createSubProFileNode(const QString &path);
 
     QStringList uiDirPaths(ProFileReader *reader) const;
@@ -197,9 +203,9 @@ private:
     Qt4ProjectType m_projectType;
     QHash<Qt4Variable, QStringList> m_varValues;
     bool m_isQBuildProject;
+    QTimer m_updateTimer;
 
     DirectoryWatcher *m_dirWatcher;
-
     friend class Qt4NodeHierarchy;
 };
 
diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp
index b3950ab63b721581430b0f31d14712bd3a13cae5..c926320193701e29529bfb93d396ad2650eaf6d7 100644
--- a/src/plugins/qt4projectmanager/qt4project.cpp
+++ b/src/plugins/qt4projectmanager/qt4project.cpp
@@ -265,7 +265,7 @@ Qt4Project::~Qt4Project()
 void Qt4Project::defaultQtVersionChanged()
 {
     if (qtVersionId(activeBuildConfiguration()) == 0)
-        update();
+        m_rootProjectNode->update();
 }
 
 void Qt4Project::qtVersionsChanged()
@@ -273,8 +273,8 @@ void Qt4Project::qtVersionsChanged()
     foreach (QString bc, buildConfigurations()) {
         if (!qt4ProjectManager()->versionManager()->version(qtVersionId(bc))->isValid()) {
             setQtVersion(bc, 0);
-            if(bc == activeBuildConfiguration())
-                update();
+            if (bc == activeBuildConfiguration())
+                m_rootProjectNode->update();
         }
     }
 }
@@ -507,9 +507,9 @@ void Qt4Project::updateCodeModel()
 }
 
 
-/*!
-  Updates complete project
-  */
+///*!
+//  Updates complete project
+//  */
 void Qt4Project::update()
 {
     // TODO Maybe remove this method completely?
@@ -663,7 +663,7 @@ QString Qt4Project::buildDirectory(const QString &buildConfiguration) const
     QString workingDirectory;
     if (value(buildConfiguration, "useShadowBuild").toBool())
         workingDirectory = value(buildConfiguration, "buildDirectory").toString();
-    if(workingDirectory.isEmpty())
+    if (workingDirectory.isEmpty())
         workingDirectory = QFileInfo(file()->fileName()).absolutePath();
     return workingDirectory;
 }
@@ -698,7 +698,7 @@ int Qt4Project::qtVersionId(const QString &buildConfiguration) const
         qDebug()<<"Looking for qtVersion ID of "<<buildConfiguration;
     int id = 0;
     QVariant vid = value(buildConfiguration, "QtVersionId");
-    if(vid.isValid()) {
+    if (vid.isValid()) {
         id = vid.toInt();
         if (m_manager->versionManager()->version(id)->isValid()) {
             return id;
@@ -711,10 +711,10 @@ int Qt4Project::qtVersionId(const QString &buildConfiguration) const
         QString vname = value(buildConfiguration, "QtVersion").toString();
         if (debug)
             qDebug()<<"  Backward compatibility reading QtVersion"<<vname;
-        if(!vname.isEmpty()) {
+        if (!vname.isEmpty()) {
             const QList<QtVersion *> &versions = m_manager->versionManager()->versions();
             foreach (const QtVersion * const version, versions) {
-                if(version->name() == vname) {
+                if (version->name() == vname) {
                     if (debug)
                         qDebug()<<"found name in versions";
                     const_cast<Qt4Project *>(this)->setValue(buildConfiguration, "QtVersionId", version->uniqueId());
@@ -828,7 +828,7 @@ void Qt4Project::checkForDeletedApplicationProjects()
 
     bool resetActiveRunConfiguration = false;
     QSharedPointer<RunConfiguration> rc(new ProjectExplorer::CustomExecutableRunConfiguration(this));
-    foreach(QSharedPointer<Qt4RunConfiguration> qt4rc, removeList) {
+    foreach (QSharedPointer<Qt4RunConfiguration> qt4rc, removeList) {
         removeRunConfiguration(qt4rc);
         if (activeRunConfiguration() == qt4rc)
             resetActiveRunConfiguration = true;
@@ -905,7 +905,7 @@ bool Qt4Project::hasSubNode(Qt4PriFileNode *root, const QString &path)
     foreach (FolderNode *fn, root->subFolderNodes()) {
         if (qobject_cast<Qt4ProFileNode *>(fn)) {
             // we aren't interested in pro file nodes
-        } else if(Qt4PriFileNode *qt4prifilenode = qobject_cast<Qt4PriFileNode *>(fn)) {
+        } else if (Qt4PriFileNode *qt4prifilenode = qobject_cast<Qt4PriFileNode *>(fn)) {
             if (hasSubNode(qt4prifilenode, path))
                 return true;
         }
diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.cpp b/src/plugins/qt4projectmanager/qt4projectmanager.cpp
index 8ff73970d5374e886a26e30d9c7c4f09b05e4a6f..2e1281682efadfb55f0b0dda604a2da8a8d992b5 100644
--- a/src/plugins/qt4projectmanager/qt4projectmanager.cpp
+++ b/src/plugins/qt4projectmanager/qt4projectmanager.cpp
@@ -102,9 +102,8 @@ void Qt4Manager::unregisterProject(Qt4Project *project)
 
 void Qt4Manager::notifyChanged(const QString &name)
 {
-    foreach(Qt4Project *pro, m_projects) {
+    foreach (Qt4Project *pro, m_projects)
         pro->notifyChanged(name);
-    }
 }
 
 void Qt4Manager::init()
diff --git a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp
index 28f7ca2a8c812f295128449a426b9bf7bcd20173..2c0b4f346970fb2bfec8fc7dba420306466fef06 100644
--- a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp
+++ b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp
@@ -33,15 +33,16 @@
 
 #include "qt4runconfiguration.h"
 
-#include "qt4project.h"
+#include "makestep.h"
 #include "profilereader.h"
 #include "qt4nodes.h"
-#include "makestep.h"
+#include "qt4project.h"
 
 #include <coreplugin/icore.h>
 #include <coreplugin/messagemanager.h>
 #include <coreplugin/variablemanager.h>
 #include <projectexplorer/buildstep.h>
+#include <utils/qtcassert.h>
 
 #include <QtGui/QFormLayout>
 #include <QtGui/QInputDialog>
@@ -148,7 +149,7 @@ QStringList Qt4RunConfiguration::commandLineArguments() const
 ProjectExplorer::Environment Qt4RunConfiguration::environment() const
 {
     Qt4Project *pro = qobject_cast<Qt4Project *>(project());
-    Q_ASSERT(pro);
+    QTC_ASSERT(pro, return ProjectExplorer::Environment());
     return pro->environment(pro->activeBuildConfiguration());
 }
 
@@ -297,7 +298,7 @@ QString Qt4RunConfiguration::qmakeBuildConfigFromBuildConfiguration(const QStrin
     QStringList makeargs = ms->value(buildConfigurationName, "makeargs").toStringList();
     if (makeargs.contains("debug"))
         return "debug";
-    else if(makeargs.contains("release"))
+    else if (makeargs.contains("release"))
         return "release";
 
     // Oh we don't have an explicit make argument
@@ -369,11 +370,12 @@ bool Qt4RunConfigurationFactory::canCreate(const QString &type) const
     return type == "Qt4ProjectManager.Qt4RunConfiguration";
 }
 
-QSharedPointer<ProjectExplorer::RunConfiguration> Qt4RunConfigurationFactory::create(ProjectExplorer::Project *project, const QString &type)
+QSharedPointer<ProjectExplorer::RunConfiguration> Qt4RunConfigurationFactory::create
+    (ProjectExplorer::Project *project, const QString &type)
 {
     Qt4Project *p = qobject_cast<Qt4Project *>(project);
-    Q_ASSERT(p);
-    Q_ASSERT(type == "Qt4ProjectManager.Qt4RunConfiguration");
+    QTC_ASSERT(p, /**/);
+    QTC_ASSERT(type == "Qt4ProjectManager.Qt4RunConfiguration", /**/);
     // The right path is set in restoreSettings
     QSharedPointer<ProjectExplorer::RunConfiguration> rc(new Qt4RunConfiguration(p, QString::null));
     return rc;
@@ -416,7 +418,7 @@ bool Qt4RunConfigurationFactoryUser::canCreate(const QString &type) const
 QSharedPointer<ProjectExplorer::RunConfiguration> Qt4RunConfigurationFactoryUser::create(ProjectExplorer::Project *project, const QString &type)
 {
     Qt4Project *p = qobject_cast<Qt4Project *>(project);
-    Q_ASSERT(p);
+    QTC_ASSERT(p, /**/);
 
     QString fileName = type.mid(QString("Qt4RunConfiguration.").size());
     return QSharedPointer<ProjectExplorer::RunConfiguration>(new Qt4RunConfiguration(p, fileName));
@@ -428,7 +430,7 @@ QStringList Qt4RunConfigurationFactoryUser::canCreate(ProjectExplorer::Project *
     if (qt4project) {
         QStringList applicationProFiles;
         QList<Qt4ProFileNode *> list = qt4project->applicationProFiles();
-        foreach(Qt4ProFileNode * node, list) {
+        foreach (Qt4ProFileNode * node, list) {
             applicationProFiles.append("Qt4RunConfiguration." + node->path());
         }
         return applicationProFiles;
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp
index 421aa3b77aeeb1c0163144cd632b972fda917bf7..246d4737bd1be74bec1437802784d53364def44a 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.cpp
+++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp
@@ -39,14 +39,16 @@
 
 #include <coreplugin/coreconstants.h>
 #include <help/helpplugin.h>
+#include <utils/qtcassert.h>
 
+#include <QtCore/QDebug>
+#include <QtCore/QProcess>
 #include <QtCore/QSettings>
 #include <QtCore/QStringRef>
 #include <QtCore/QTime>
-#include <QtCore/QProcess>
-#include <QtGui/QHeaderView>
+
 #include <QtGui/QFileDialog>
-#include <QtCore/QDebug>
+#include <QtGui/QHeaderView>
 #include <QtGui/QMessageBox>
 
 using namespace Qt4ProjectManager::Internal;
@@ -114,9 +116,7 @@ void QtVersionManager::addVersion(QtVersion *version)
 void QtVersionManager::updateDocumentation()
 {
     Help::HelpManager *helpManager = m_core->pluginManager()->getObject<Help::HelpManager>();
-    Q_ASSERT(helpManager);
-    if (!helpManager)
-        return;
+    QTC_ASSERT(helpManager, return);
     QStringList fileEndings = QStringList() << "/qch/qt.qch" << "/qch/qmake.qch" << "/qch/designer.qch";
     QStringList files;
     foreach (QtVersion *version, m_versions) {
@@ -158,7 +158,7 @@ QWidget *QtVersionManager::createPage(QWidget *parent)
 void QtVersionManager::updateUniqueIdToIndexMap()
 {
     m_uniqueIdToIndex.clear();
-    for(int i=0; i<m_versions.size(); ++i)
+    for (int i = 0; i < m_versions.size(); ++i)
         m_uniqueIdToIndex.insert(m_versions.at(i)->uniqueId(), i);
 }
 
@@ -225,7 +225,7 @@ QtVersion *QtVersionManager::version(int id) const
     if (pos != -1)
         return m_versions.at(pos);
 
-    if(m_defaultVersion < m_versions.count())
+    if (m_defaultVersion < m_versions.count())
         return m_versions.at(m_defaultVersion);
     else
         return m_emptyVersion;
@@ -248,17 +248,17 @@ void QtVersionManager::addNewVersionsFromInstaller()
     bool defaultVersionWasReset = false;
     foreach (QString newVersion, newVersionsList) {
         QStringList newVersionData = newVersion.split('=');
-        if(newVersionData.count()>=2) {
+        if (newVersionData.count()>=2) {
             if (QDir(newVersionData[1]).exists()) {
                 QtVersion *version = new QtVersion(newVersionData[0], newVersionData[1], m_idcount++ );
-                if(newVersionData.count() >= 3)
+                if (newVersionData.count() >= 3)
                     version->setMingwDirectory(newVersionData[2]);
-                if(newVersionData.count() >= 4)
+                if (newVersionData.count() >= 4)
                     version->setPrependPath(newVersionData[3]);
 
                 bool versionWasAlreadyInList = false;
                 foreach(const QtVersion * const it, m_versions) {
-                    if(QDir(version->path()).canonicalPath() == QDir(it->path()).canonicalPath()) {
+                    if (QDir(version->path()).canonicalPath() == QDir(it->path()).canonicalPath()) {
                         versionWasAlreadyInList = true;
                         break;
                     }
@@ -314,7 +314,7 @@ QStringList QtVersionManager::possibleQMakeCommands()
     return result;
 }
 
-bool QtVersionManager::checkQMakeVersion(const QString &qmakePath)
+QString QtVersionManager::qtVersionForQMake(const QString &qmakePath)
 {
     QProcess qmake;
     qmake.start(qmakePath, QStringList()<<"--version");
@@ -323,9 +323,12 @@ bool QtVersionManager::checkQMakeVersion(const QString &qmakePath)
     QString output = qmake.readAllStandardOutput();
     QRegExp regexp("(QMake version|Qmake version:)[\\s]*([\\d.]*)");
     regexp.indexIn(output);
-    if (regexp.cap(2).startsWith("2."))
-        return true;
-    return false;
+    if (regexp.cap(2).startsWith("2.")) {
+        QRegExp regexp2("Using Qt version[\\s]*([\\d\\.]*)");
+        regexp2.indexIn(output);
+        return regexp2.cap(1);
+    }
+    return QString();
 }
 
 QString QtVersionManager::findSystemQt() const
@@ -336,7 +339,7 @@ QString QtVersionManager::findSystemQt() const
         foreach (const QString &possibleCommand, possibleQMakeCommands()) {
             QFileInfo qmake(path + "/" + possibleCommand);
             if (qmake.exists()) {
-                if (checkQMakeVersion(qmake.absoluteFilePath())) {
+                if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull()) {
                     QDir dir(qmake.absoluteDir());
                     dir.cdUp();
                     return dir.absolutePath();
@@ -349,7 +352,7 @@ QString QtVersionManager::findSystemQt() const
 
 QtVersion *QtVersionManager::currentQtVersion() const
 {
-    if(m_defaultVersion < m_versions.count())
+    if (m_defaultVersion < m_versions.count())
         return m_versions.at(m_defaultVersion);
     else
         return m_emptyVersion;
@@ -465,27 +468,27 @@ void QtDirWidget::updateState()
 void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item)
 {
     m_ui.msvcComboBox->setVisible(false);
-    if(item) {
+    if (item) {
         int index = m_ui.qtdirList->indexOfTopLevelItem(item);
         m_ui.errorLabel->setText("");
         QtVersion::ToolchainType t = m_versions.at(index)->toolchainType();
-        if(t == QtVersion::MinGW) {
+        if (t == QtVersion::MinGW) {
             m_ui.msvcComboBox->setVisible(false);
             m_ui.msvcLabel->setVisible(false);
             m_ui.mingwLineEdit->setVisible(true);
             m_ui.mingwLabel->setVisible(true);
             m_ui.mingwBrowseButton->setVisible(true);
             m_ui.mingwLineEdit->setText(m_versions.at(index)->mingwDirectory());
-        } else if(t == QtVersion::MSVC || t == QtVersion::WINCE){
+        } else if (t == QtVersion::MSVC || t == QtVersion::WINCE){
             m_ui.msvcComboBox->setVisible(false);
             m_ui.msvcLabel->setVisible(true);
             m_ui.mingwLineEdit->setVisible(false);
             m_ui.mingwLabel->setVisible(false);
             m_ui.mingwBrowseButton->setVisible(false);
             QList<MSVCEnvironment> msvcenvironments = MSVCEnvironment::availableVersions();
-            if(msvcenvironments.count() == 0) {
+            if (msvcenvironments.count() == 0) {
                 m_ui.msvcLabel->setText(tr("No Visual Studio Installation found"));
-            } else if(msvcenvironments.count() == 1) {
+            } else if (msvcenvironments.count() == 1) {
                 m_ui.msvcLabel->setText( msvcenvironments.at(0).description());
             } else {
                  m_ui.msvcComboBox->setVisible(true);
@@ -500,7 +503,7 @@ void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item)
                  }
                  m_ui.msvcComboBox->blockSignals(block);
             }
-        } else if(t == QtVersion::INVALID) {
+        } else if (t == QtVersion::INVALID) {
             m_ui.msvcComboBox->setVisible(false);
             m_ui.msvcLabel->setVisible(false);
             m_ui.mingwLineEdit->setVisible(false);
@@ -517,7 +520,10 @@ void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item)
             m_ui.mingwLineEdit->setVisible(false);
             m_ui.mingwLabel->setVisible(false);
             m_ui.mingwBrowseButton->setVisible(false);
-            m_ui.errorLabel->setText("Found qt version: " + m_versions.at(index)->mkspec());
+            m_ui.errorLabel->setText("Found Qt version "
+                                     + m_versions.at(index)->qtVersionString()
+                                     + " using mkspec "
+                                     + m_versions.at(index)->mkspec());
         }
     } else {
         m_ui.msvcComboBox->setVisible(false);
@@ -530,7 +536,7 @@ void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item)
 
 void QtDirWidget::versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old)
 {
-    if(old) {
+    if (old) {
         fixQtVersionName(m_ui.qtdirList->indexOfTopLevelItem(old));
     }
     if (item) {
@@ -590,7 +596,7 @@ void QtDirWidget::defaultChanged(int)
 void QtDirWidget::updateCurrentQtName()
 {
     QTreeWidgetItem *currentItem = m_ui.qtdirList->currentItem();
-    Q_ASSERT(currentItem);
+    QTC_ASSERT(currentItem, return);
     int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem);
     m_versions[currentItemIndex]->setName(m_ui.nameEdit->text());
     currentItem->setText(0, m_versions[currentItemIndex]->name());
@@ -601,7 +607,7 @@ void QtDirWidget::updateCurrentQtName()
 
 void QtDirWidget::finish()
 {
-    if(QTreeWidgetItem *item = m_ui.qtdirList->currentItem())
+    if (QTreeWidgetItem *item = m_ui.qtdirList->currentItem())
         fixQtVersionName(m_ui.qtdirList->indexOfTopLevelItem(item));
 }
 
@@ -612,9 +618,9 @@ void QtDirWidget::finish()
 void QtDirWidget::fixQtVersionName(int index)
 {
     int count = m_versions.count();
-    for(int i=0; i<count; ++i) {
-        if(i != index) {
-            if(m_versions.at(i)->name() == m_versions.at(index)->name()) {
+    for (int i = 0; i < count; ++i) {
+        if (i != index) {
+            if (m_versions.at(i)->name() == m_versions.at(index)->name()) {
                 // Same name, find new name
                 QString name = m_versions.at(index)->name();
                 QRegExp regexp("^(.*)\\((\\d)\\)$");
@@ -639,7 +645,7 @@ void QtDirWidget::fixQtVersionName(int index)
 void QtDirWidget::updateCurrentQtPath()
 {
     QTreeWidgetItem *currentItem = m_ui.qtdirList->currentItem();
-    Q_ASSERT(currentItem);
+    QTC_ASSERT(currentItem, return);
     int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem);
     m_versions[currentItemIndex]->setPath(m_ui.pathEdit->text());
     currentItem->setText(1, m_versions[currentItemIndex]->path());
@@ -650,7 +656,7 @@ void QtDirWidget::updateCurrentQtPath()
 void QtDirWidget::updateCurrentMingwDirectory()
 {
     QTreeWidgetItem *currentItem = m_ui.qtdirList->currentItem();
-    Q_ASSERT(currentItem);
+    QTC_ASSERT(currentItem, return);
     int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem);
     m_versions[currentItemIndex]->setMingwDirectory(m_ui.mingwLineEdit->text());
 }
@@ -659,14 +665,14 @@ void QtDirWidget::msvcVersionChanged()
 {
     const QString &msvcVersion = m_ui.msvcComboBox->currentText();
     QTreeWidgetItem *currentItem = m_ui.qtdirList->currentItem();
-    Q_ASSERT(currentItem);
+    QTC_ASSERT(currentItem, return);
     int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem);
     m_versions[currentItemIndex]->setMsvcVersion(msvcVersion);
 
     //get descriptionx
     QList<MSVCEnvironment> msvcEnvironments = MSVCEnvironment::availableVersions();
     foreach(const MSVCEnvironment &msvcEnv, msvcEnvironments) {
-        if(msvcEnv.name() == msvcVersion) {
+        if (msvcEnv.name() == msvcVersion) {
             m_ui.msvcLabel->setText(msvcEnv.description());
             break;
         }
@@ -691,7 +697,7 @@ QtVersion::QtVersion(const QString &name, const QString &path, int id, bool isSy
     : m_name(name), m_isSystemVersion(isSystemVersion), m_notInstalled(false), m_defaultConfigIsDebug(true), m_defaultConfigIsDebugAndRelease(true)
 {
     setPath(path);
-    if(id == -1)
+    if (id == -1)
         m_id = getUniqueId();
     else
         m_id = id;
@@ -734,6 +740,12 @@ QString QtVersion::mkspecPath() const
     return m_mkspecFullPath;
 }
 
+QString QtVersion::qtVersionString() const
+{
+    qmakeCommand();
+    return m_qtVersionString;
+}
+
 QHash<QString,QString> QtVersion::versionInfo() const
 {
     updateVersionInfo();
@@ -860,7 +872,7 @@ QtVersion::QmakeBuildConfig QtVersionManager::scanMakefileForQmakeConfig(const Q
                     //Now chop into parts that are intresting
                     QStringList parts;
                     int lastpos = 0;
-                    for(int i=1; i<line.size(); ++i) {
+                    for (int i = 1; i < line.size(); ++i) {
                         if (line.at(i) == QLatin1Char(' ') && line.at(i-1) != QLatin1Char('\\')) {
                             // found a part
                             parts.append(line.mid(lastpos, i-lastpos));
@@ -874,7 +886,7 @@ QtVersion::QmakeBuildConfig QtVersionManager::scanMakefileForQmakeConfig(const Q
                         qDebug()<<"part appended:"<<line.mid(lastpos);
 
                     foreach(const QString &part, parts) {
-                        if(debugScan)
+                        if (debugScan)
                             qDebug()<<"now interpreting part"<<part;
                         bool setFlags;
                         // Now try to understand each part for that we do a rather stupid approach, optimize it if you care
@@ -893,7 +905,7 @@ QtVersion::QmakeBuildConfig QtVersionManager::scanMakefileForQmakeConfig(const Q
                                 qDebug()<<"part has setFlags:"<<setFlags;
                             // now loop forward, looking for something that looks like debug, release or debug_and_release
 
-                            for(int i=0; i<part.size(); ++i) {
+                            for (int i = 0; i < part.size(); ++i) {
                                 int left = part.size() - i;
                                 if (left >= 17  && QStringRef(&part, i, 17) == "debug_and_release") {
                                         if (setFlags)
@@ -910,7 +922,7 @@ QtVersion::QmakeBuildConfig QtVersionManager::scanMakefileForQmakeConfig(const Q
                                             result = QtVersion::QmakeBuildConfig(result | QtVersion::DebugBuild);
                                         if (debugScan)
                                             qDebug()<<"found release new value"<<result;
-                                        i +=7;
+                                        i += 7;
                                 } else if (left >= 5 && QStringRef(&part, i, 5) == "debug") {
                                         if (setFlags)
                                             result = QtVersion::QmakeBuildConfig(result  | QtVersion::DebugBuild);
@@ -918,7 +930,7 @@ QtVersion::QmakeBuildConfig QtVersionManager::scanMakefileForQmakeConfig(const Q
                                             result = QtVersion::QmakeBuildConfig(result  & ~QtVersion::DebugBuild);
                                         if (debugScan)
                                             qDebug()<<"found debug new value"<<result;
-                                        i+=5;
+                                        i += 5;
                                 }
                             }
                         }
@@ -1004,9 +1016,9 @@ void QtVersion::updateVersionInfo() const
                     foreach(const QString &value, values) {
                         if (value == "debug")
                             m_defaultConfigIsDebug = true;
-                        else if(value == "release")
+                        else if (value == "release")
                             m_defaultConfigIsDebug = false;
-                        else if(value == "build_all")
+                        else if (value == "build_all")
                             m_defaultConfigIsDebugAndRelease = true;
                     }
                 }
@@ -1031,11 +1043,11 @@ void QtVersion::updateMkSpec() const
     QString mkspec;
 //    QFile f(path() + "/.qmake.cache");
 //    if (f.exists() && f.open(QIODevice::ReadOnly)) {
-//        while(!f.atEnd()) {
+//        while (!f.atEnd()) {
 //            QByteArray line = f.readLine();
-//            if(line.startsWith("QMAKESPEC")) {
+//            if (line.startsWith("QMAKESPEC")) {
 //                const QList<QByteArray> &temp = line.split('=');
-//                if(temp.size() == 2) {
+//                if (temp.size() == 2) {
 //                    mkspec = temp.at(1).trimmed();
 //                    if (mkspec.startsWith("$$QT_BUILD_TREE/mkspecs/"))
 //                        mkspec = mkspec.mid(QString("$$QT_BUILD_TREE/mkspecs/").length());
@@ -1058,9 +1070,9 @@ void QtVersion::updateMkSpec() const
 #ifdef Q_OS_WIN
         QFile f2(mkspecPath + "/qmake.conf");
         if (f2.exists() && f2.open(QIODevice::ReadOnly)) {
-            while(!f2.atEnd()) {
+            while (!f2.atEnd()) {
                 QByteArray line = f2.readLine();
-                if(line.startsWith("QMAKESPEC_ORIGINAL")) {
+                if (line.startsWith("QMAKESPEC_ORIGINAL")) {
                     const QList<QByteArray> &temp = line.split('=');
                     if (temp.size() == 2) {
                         mkspec = temp.at(1);
@@ -1073,9 +1085,9 @@ void QtVersion::updateMkSpec() const
 #elif defined(Q_OS_MAC)
         QFile f2(mkspecPath + "/qmake.conf");
         if (f2.exists() && f2.open(QIODevice::ReadOnly)) {
-            while(!f2.atEnd()) {
+            while (!f2.atEnd()) {
                 QByteArray line = f2.readLine();
-                if(line.startsWith("MAKEFILE_GENERATOR")) {
+                if (line.startsWith("MAKEFILE_GENERATOR")) {
                     const QList<QByteArray> &temp = line.split('=');
                     if (temp.size() == 2) {
                         const QByteArray &value = temp.at(1);
@@ -1106,7 +1118,7 @@ void QtVersion::updateMkSpec() const
 
     m_mkspecFullPath = mkspec;
     int index = mkspec.lastIndexOf('/');
-    if(index == -1)
+    if (index == -1)
         index = mkspec.lastIndexOf('\\');
     QString mkspecDir = QDir(m_path + "/mkspecs/").canonicalPath();
     if (index >= 0 && QDir(mkspec.left(index)).canonicalPath() == mkspecDir)
@@ -1123,7 +1135,7 @@ QString QtVersion::makeCommand() const
     const QString &spec = mkspec();
     if (spec.contains("win32-msvc") || spec.contains(QLatin1String("win32-icc")))
         return "nmake.exe";
-    else if(spec.startsWith("wince"))
+    else if (spec.startsWith("wince"))
         return "nmake.exe";
     else
         return "mingw32-make.exe";
@@ -1140,11 +1152,13 @@ QString QtVersion::qmakeCommand() const
         return m_qmakeCommand;
 
     QDir qtDir = path() + "/bin/";
-    foreach(const QString &possibleCommand, QtVersionManager::possibleQMakeCommands()) {
+    foreach (const QString &possibleCommand, QtVersionManager::possibleQMakeCommands()) {
         QString s = qtDir.absoluteFilePath(possibleCommand);
         QFileInfo qmake(s);
         if (qmake.exists() && qmake.isExecutable()) {
-            if (QtVersionManager::checkQMakeVersion(qmake.absoluteFilePath())) {
+            QString qtVersion = QtVersionManager::qtVersionForQMake(qmake.absoluteFilePath());
+            if (!qtVersion.isNull()) {
+                m_qtVersionString = qtVersion;
                 m_qmakeCommand = qmake.absoluteFilePath();
                 return qmake.absoluteFilePath();
             }
@@ -1158,13 +1172,13 @@ QtVersion::ToolchainType QtVersion::toolchainType() const
     if (!isValid())
         return INVALID;
     const QString &spec = mkspec();
-    if(spec.contains("win32-msvc") || spec.contains(QLatin1String("win32-icc")))
+    if (spec.contains("win32-msvc") || spec.contains(QLatin1String("win32-icc")))
         return MSVC;
-    else if(spec == "win32-g++")
+    else if (spec == "win32-g++")
         return MinGW;
-    else if(spec == QString::null)
+    else if (spec == QString::null)
         return INVALID;
-    else if(spec.startsWith("wince"))
+    else if (spec.startsWith("wince"))
         return WINCE;
     else
         return OTHER;
@@ -1210,32 +1224,32 @@ Environment QtVersion::addToEnvironment(const Environment &env)
     // or add Mingw dirs
     // or do nothing on other
     QtVersion::ToolchainType t = toolchainType();
-    if(t == QtVersion::MinGW) {
+    if (t == QtVersion::MinGW) {
         QFileInfo mingwFileInfo(m_mingwDirectory + "/bin");
-        if(mingwFileInfo.exists())
+        if (mingwFileInfo.exists())
             e.prependOrSetPath(m_mingwDirectory + "/bin");
-    } else if(t == QtVersion::MSVC) {
+    } else if (t == QtVersion::MSVC) {
         QList<MSVCEnvironment> list = MSVCEnvironment::availableVersions();
-        if(list.count() == 1) {
+        if (list.count() == 1) {
             e = list.at(0).addToEnvironment(e);
         } else {
             foreach(const MSVCEnvironment &m, list) {
-                if(m.name() == m_msvcVersion) {
+                if (m.name() == m_msvcVersion) {
                     e = m.addToEnvironment(e);
                     break;
                 }
             }
         }
-    } else if(t == QtVersion::WINCE) {
+    } else if (t == QtVersion::WINCE) {
         QString msvcPath;
         // Find MSVC path
         QList<MSVCEnvironment> list = MSVCEnvironment::availableVersions();
-        if(list.count() == 1) {
+        if (list.count() == 1) {
             msvcPath = list.at(0).path();
             e = list.at(0).addToEnvironment(e);
         } else {
             foreach(const MSVCEnvironment &m, list) {
-                if(m.name() == m_msvcVersion) {
+                if (m.name() == m_msvcVersion) {
                     e = m.addToEnvironment(e);
                     msvcPath = m.path();
                     break;
@@ -1254,8 +1268,8 @@ Environment QtVersion::addToEnvironment(const Environment &env)
         CeSdkHandler cesdkhandler;
         cesdkhandler.parse(msvcPath);
         e = cesdkhandler.find(platformName).addToEnvironment(e);
-    } else if(t == QtVersion::OTHER) {
-        if(!m_prependPath.isEmpty())
+    } else if (t == QtVersion::OTHER) {
+        if (!m_prependPath.isEmpty())
             e.prependOrSetPath(m_prependPath);
     }
     return e;
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h
index a8ca95708959d48710b91491fab86e39617c8880..d13ba7c3e0067383d5a40d5b353692b361f5d7b5 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.h
+++ b/src/plugins/qt4projectmanager/qtversionmanager.h
@@ -70,6 +70,7 @@ public:
     QString mkspecPath() const;
     QString makeCommand() const;
     QString qmakeCommand() const;
+    QString qtVersionString() const;
     // Returns the PREFIX, BINPREFIX, DOCPREFIX and similar information
     QHash<QString,QString> versionInfo() const;
 
@@ -119,6 +120,9 @@ private:
     mutable bool m_defaultConfigIsDebug;
     mutable bool m_defaultConfigIsDebugAndRelease;
     mutable QString m_qmakeCommand;
+    // This is updated on first call to qmakeCommand
+    // That function is called from updateVersionInfo()
+    mutable QString m_qtVersionString;
     Q_DISABLE_COPY(QtVersion);
 };
 
@@ -189,7 +193,7 @@ public:
     // returns something like qmake4, qmake, qmake-qt4 or whatever distributions have chosen (used by QtVersion)
     static QStringList possibleQMakeCommands();
     // return true if the qmake at qmakePath is qt4 (used by QtVersion)
-    static bool checkQMakeVersion(const QString &qmakePath);
+    static QString qtVersionForQMake(const QString &qmakePath);
 signals:
     void defaultQtVersionChanged();
     void qtVersionsChanged();
diff --git a/src/plugins/qt4projectmanager/wizards/librarywizarddialog.cpp b/src/plugins/qt4projectmanager/wizards/librarywizarddialog.cpp
index 53972631c6884fb19bf94f33fd31c8284eba27fe..c95bea8217b7c944aaff6712db02c89c3cb596fc 100644
--- a/src/plugins/qt4projectmanager/wizards/librarywizarddialog.cpp
+++ b/src/plugins/qt4projectmanager/wizards/librarywizarddialog.cpp
@@ -32,12 +32,14 @@
 ***************************************************************************/
 
 #include "librarywizarddialog.h"
+
 #include "consoleappwizard.h"
-#include "modulespage.h"
 #include "filespage.h"
 #include "libraryparameters.h"
+#include "modulespage.h"
 
 #include <utils/projectintropage.h>
+#include <utils/qtcassert.h>
 
 #include <QtGui/QComboBox>
 #include <QtGui/QLabel>
@@ -93,7 +95,7 @@ static QString pluginDependencies(const PluginBaseClasses *plb)
                                QString(QLatin1String(plb->dependentModules)).split(blank) :
                                QStringList();
     pluginModules.push_back(QLatin1String(plb->module));
-    foreach(const QString &module, pluginModules) {
+    foreach (const QString &module, pluginModules) {
         if (!dependencies.isEmpty())
             dependencies += blank;
         dependencies += ModulesPage::idOfModule(module);
@@ -231,7 +233,7 @@ void LibraryWizardDialog::slotCurrentIdChanged(int id)
                 qDebug("initializing for plugins");
             QStringList baseClasses;
             const int pluginBaseClassCount = sizeof(pluginBaseClasses)/sizeof(PluginBaseClasses);
-            Q_ASSERT(defaultPluginBaseClass < pluginBaseClassCount);
+            QTC_ASSERT(defaultPluginBaseClass < pluginBaseClassCount, return);
             for (int i = 0; i < pluginBaseClassCount; i++)
                 baseClasses.push_back(QLatin1String(pluginBaseClasses[i].name));
             m_filesPage->setBaseClassChoices(baseClasses);
diff --git a/src/plugins/qt4projectmanager/wizards/modulespage.cpp b/src/plugins/qt4projectmanager/wizards/modulespage.cpp
index a2b5b3e4f09f73c733fbcb370b49778f51957825..7e11c50de9a11a41ef0968ca6313308c685bf05c 100644
--- a/src/plugins/qt4projectmanager/wizards/modulespage.cpp
+++ b/src/plugins/qt4projectmanager/wizards/modulespage.cpp
@@ -32,15 +32,18 @@
 ***************************************************************************/
 
 #include "modulespage.h"
+
 #include "speinfo.h"
 
+#include <utils/qtcassert.h>
+
+#include <QtCore/QDebug>
+
+#include <QtGui/QCheckBox>
 #include <QtGui/QLabel>
 #include <QtGui/QLayout>
-#include <QtGui/QCheckBox>
 #include <QtGui/QWidget>
 
-#include <QtCore/QDebug>
-
 #include <math.h>
 
 using namespace Qt4ProjectManager::Internal;
@@ -101,17 +104,15 @@ QString ModulesPage::deselectedModules() const
 void ModulesPage::setModuleSelected(const QString &module, bool selected) const
 {
     QCheckBox *checkBox = m_moduleCheckBoxMap[module];
-    Q_ASSERT(checkBox);
-    if (checkBox)
-        checkBox->setCheckState(selected?Qt::Checked:Qt::Unchecked);
+    QTC_ASSERT(checkBox, return);
+    checkBox->setCheckState(selected?Qt::Checked:Qt::Unchecked);
 }
 
 void ModulesPage::setModuleEnabled(const QString &module, bool enabled) const
 {
     QCheckBox *checkBox = m_moduleCheckBoxMap[module];
-    Q_ASSERT(checkBox);
-    if (checkBox)
-        checkBox->setEnabled(enabled);
+    QTC_ASSERT(checkBox, return);
+    checkBox->setEnabled(enabled);
 }
 
 QString ModulesPage::modules(bool selected) const
diff --git a/src/plugins/qtscripteditor/qtscripteditor.cpp b/src/plugins/qtscripteditor/qtscripteditor.cpp
index fa10cdd51027bf231a30000f4c7908efa6e545e5..673c7a02fd8a1560ed2783bf8ffa79f58ee134d7 100644
--- a/src/plugins/qtscripteditor/qtscripteditor.cpp
+++ b/src/plugins/qtscripteditor/qtscripteditor.cpp
@@ -159,14 +159,12 @@ void ScriptEditor::contextMenuEvent(QContextMenuEvent *e)
 
     if (Core::IActionContainer *mcontext = m_core->actionManager()->actionContainer(QtScriptEditor::Constants::M_CONTEXT)) {
         QMenu *contextMenu = mcontext->menu();
-        foreach(QAction *action, contextMenu->actions()) {
+        foreach (QAction *action, contextMenu->actions())
             menu->addAction(action);
-        }
     }
 
     menu->exec(e->globalPos());
     delete menu;
-
 }
 
 } // namespace Internal
diff --git a/src/plugins/qtscripteditor/qtscripteditorplugin.cpp b/src/plugins/qtscripteditor/qtscripteditorplugin.cpp
index 0cc69b82c45c8366554a010304387521b7db1d8f..9f724d4d09d39b303c8aa01f55c358031710e1d8 100644
--- a/src/plugins/qtscripteditor/qtscripteditorplugin.cpp
+++ b/src/plugins/qtscripteditor/qtscripteditorplugin.cpp
@@ -32,10 +32,11 @@
 ***************************************************************************/
 
 #include "qtscripteditorplugin.h"
+
+#include "qscripthighlighter.h"
+#include "qtscripteditor.h"
 #include "qtscripteditorconstants.h"
 #include "qtscripteditorfactory.h"
-#include "qtscripteditor.h"
-#include "qscripthighlighter.h"
 
 #include <coreplugin/icore.h>
 #include <coreplugin/coreconstants.h>
@@ -47,6 +48,7 @@
 #include <texteditor/texteditorconstants.h>
 #include <texteditor/texteditorsettings.h>
 #include <texteditor/textfilewizard.h>
+#include <utils/qtcassert.h>
 
 #include <QtCore/qplugin.h>
 #include <QtCore/QDebug>
@@ -108,7 +110,7 @@ void QtScriptEditorPlugin::extensionsInitialized()
 
 void QtScriptEditorPlugin::initializeEditor(QtScriptEditor::Internal::ScriptEditor *editor)
 {
-    Q_ASSERT(m_instance);
+    QTC_ASSERT(m_instance, /**/);
 
     TextEditor::TextEditorSettings *settings = TextEditor::TextEditorSettings::instance();
     connect(settings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
diff --git a/src/plugins/qtscripteditor/qtscripthighlighter.cpp b/src/plugins/qtscripteditor/qtscripthighlighter.cpp
index b362f6a2ad6de5cbebb824a9361d4417e33ed60d..0e7cd342cbd681dc0acd6bf3b364c50fa2ad8dac 100644
--- a/src/plugins/qtscripteditor/qtscripthighlighter.cpp
+++ b/src/plugins/qtscripteditor/qtscripthighlighter.cpp
@@ -33,6 +33,8 @@
 
 #include "qtscripthighlighter.h"
 
+#include <utils/qtcassert.h>
+
 namespace QtScriptEditor {
 namespace Internal {
 
@@ -94,7 +96,7 @@ void QtScriptHighlighter::onBlockEnd(int state, int firstNonSpace)
         blockData->setCollapseMode(TextEditor::TextBlockUserData::NoCollapse);
     }
     if (!m_currentBlockParentheses.isEmpty()) {
-        Q_ASSERT(blockData);
+        QTC_ASSERT(blockData, return);
         int collapse = Parenthesis::collapseAtPos(m_currentBlockParentheses);
         if (collapse >= 0) {
             if (collapse == firstNonSpace)
diff --git a/src/plugins/quickopen/quickopenconstants.h b/src/plugins/quickopen/quickopenconstants.h
index 8ae0380f371113043f1855a46ebf3e58839bb54b..9cce426877073af1513350da7fbaeb204a25df48 100644
--- a/src/plugins/quickopen/quickopenconstants.h
+++ b/src/plugins/quickopen/quickopenconstants.h
@@ -38,7 +38,7 @@ namespace QuickOpen {
 namespace Constants {
 
 const char * const FILTER_OPTIONS_PAGE = "Filters";
-const char * const QUICKOPEN_CATEGORY = "QuickOpen";
+const char * const QUICKOPEN_CATEGORY = "Locator";
 const char * const TASK_INDEX = "QuickOpen.Task.Index";
 
 } // namespace Constants
diff --git a/src/plugins/quickopen/quickopenmanager.cpp b/src/plugins/quickopen/quickopenmanager.cpp
index 99e9bcc6f1d6ca18046a9050a1763a022964f372..1cabeb6bc2dd795c8cf9d69384b019d113b09fc2 100644
--- a/src/plugins/quickopen/quickopenmanager.cpp
+++ b/src/plugins/quickopen/quickopenmanager.cpp
@@ -35,6 +35,7 @@
 #include "quickopentoolwindow.h"
 
 #include <extensionsystem/pluginmanager.h>
+#include <utils/qtcassert.h>
 
 using namespace QuickOpen;
 using namespace QuickOpen::Internal;
@@ -57,6 +58,6 @@ QuickOpenManager::~QuickOpenManager()
 void QuickOpenManager::show(const QString &text,
                             int selectionStart, int selectionLength)
 {
-    Q_ASSERT(m_toolWindow);
+    QTC_ASSERT(m_toolWindow, return);
     m_toolWindow->show(text, selectionStart, selectionLength);
 }
diff --git a/src/plugins/quickopen/quickopentoolwindow.cpp b/src/plugins/quickopen/quickopentoolwindow.cpp
index 7184a05fa1f84f061aeef528bc6a686546e5aec3..211947be8d056facedf447e9107cb81e02c66928 100644
--- a/src/plugins/quickopen/quickopentoolwindow.cpp
+++ b/src/plugins/quickopen/quickopentoolwindow.cpp
@@ -51,6 +51,7 @@ QT_END_NAMESPACE
 #include <coreplugin/coreconstants.h>
 #include <coreplugin/fileiconprovider.h>
 #include <utils/fancylineedit.h>
+#include <utils/qtcassert.h>
 
 #include <QtCore/QFileInfo>
 #include <QtCore/QFile>
@@ -263,7 +264,7 @@ QuickOpenToolWindow::QuickOpenToolWindow(QuickOpenPlugin *qop) :
     // Explcitly hide the completion list popup.
     m_completionList->hide();
 
-    setWindowTitle("Quick Open");
+    setWindowTitle("Locate...");
     resize(200, 90);
     QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
     sizePolicy.setHorizontalStretch(0);
@@ -280,7 +281,7 @@ QuickOpenToolWindow::QuickOpenToolWindow(QuickOpenPlugin *qop) :
     QPixmap image(Core::Constants::ICON_MAGNIFIER);
     m_fileLineEdit->setPixmap(image);
     m_fileLineEdit->setUseLayoutDirection(true);
-    m_fileLineEdit->setHintText(tr("Type to QuickOpen"));
+    m_fileLineEdit->setHintText(tr("Type to locate"));
     m_fileLineEdit->setFocusPolicy(Qt::ClickFocus);
 
     m_fileLineEdit->installEventFilter(this);
@@ -452,9 +453,9 @@ void QuickOpenToolWindow::filterSelected()
 {
     const char * const TEXT = "<type here>";
     QAction *action = qobject_cast<QAction*>(sender());
-    Q_ASSERT(action);
+    QTC_ASSERT(action, return);
     IQuickOpenFilter *filter = action->data().value<IQuickOpenFilter*>();
-    Q_ASSERT(filter);
+    QTC_ASSERT(filter, return);
     show(filter->shortcutString() + " " + TEXT,
          filter->shortcutString().length() + 1,
          QString(TEXT).length());
diff --git a/src/plugins/quickopen/settingspage.cpp b/src/plugins/quickopen/settingspage.cpp
index 8fa032ffcacb696c113cffec3f8c20909ffe4580..76263c731badd7a09f6f6f383ec7f7045f857e43 100644
--- a/src/plugins/quickopen/settingspage.cpp
+++ b/src/plugins/quickopen/settingspage.cpp
@@ -32,13 +32,15 @@
 ***************************************************************************/
 
 #include "settingspage.h"
+
 #include "quickopenplugin.h"
 #include "iquickopenfilter.h"
 #include "directoryfilter.h"
 
-#include <QtGui/QMessageBox>
-
 #include <qtconcurrent/QtConcurrentTools>
+#include <utils/qtcassert.h>
+
+#include <QtGui/QMessageBox>
 
 Q_DECLARE_METATYPE(QuickOpen::IQuickOpenFilter*)
 
@@ -46,7 +48,7 @@ using namespace QuickOpen;
 using namespace QuickOpen::Internal;
 
 SettingsPage::SettingsPage(Core::ICore *core, QuickOpenPlugin *plugin)
-        : m_core(core), m_plugin(plugin), m_page(0)
+    : m_core(core), m_plugin(plugin), m_page(0)
 {
 }
 
@@ -144,9 +146,10 @@ void SettingsPage::configureFilter(QListWidgetItem *item)
 {
     if (!item)
         item = m_ui.filterList->currentItem();
-    Q_ASSERT(item);
+    QTC_ASSERT(item, return);
     IQuickOpenFilter *filter = item->data(Qt::UserRole).value<IQuickOpenFilter *>();
-    Q_ASSERT(filter);
+    QTC_ASSERT(filter, return);
+
     if (!filter->isConfigurable())
         return;
     bool needsRefresh = false;
@@ -172,9 +175,9 @@ void SettingsPage::addCustomFilter()
 void SettingsPage::removeCustomFilter()
 {
     QListWidgetItem *item = m_ui.filterList->currentItem();
-    Q_ASSERT(item);
+    QTC_ASSERT(item, return);
     IQuickOpenFilter *filter = item->data(Qt::UserRole).value<IQuickOpenFilter *>();
-    Q_ASSERT(m_customFilters.contains(filter));
+    QTC_ASSERT(m_customFilters.contains(filter), return);
     m_filters.removeAll(filter);
     m_customFilters.removeAll(filter);
     m_refreshFilters.removeAll(filter);
diff --git a/src/plugins/resourceeditor/resourceeditorplugin.cpp b/src/plugins/resourceeditor/resourceeditorplugin.cpp
index 43ad4ddd90c3ec8a205868d00550c598846054db..44284f06fd7d1b939108495856de18cd8bfab67a 100644
--- a/src/plugins/resourceeditor/resourceeditorplugin.cpp
+++ b/src/plugins/resourceeditor/resourceeditorplugin.cpp
@@ -32,6 +32,7 @@
 ***************************************************************************/
 
 #include "resourceeditorplugin.h"
+
 #include "resourceeditorw.h"
 #include "resourceeditorconstants.h"
 #include "resourcewizard.h"
@@ -44,6 +45,8 @@
 #include <coreplugin/actionmanager/actionmanagerinterface.h>
 #include <coreplugin/editormanager/editormanager.h>
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/qplugin.h>
 #include <QtGui/QAction>
 
@@ -122,10 +125,11 @@ void ResourceEditorPlugin::onUndoStackChanged(ResourceEditorW const *editor,
     }
 }
 
-ResourceEditorW * ResourceEditorPlugin::currentEditor() const {
+ResourceEditorW * ResourceEditorPlugin::currentEditor() const
+{
     ResourceEditorW * const focusEditor = qobject_cast<ResourceEditorW *>(
             m_core->editorManager()->currentEditor());
-    Q_ASSERT(focusEditor);
+    QTC_ASSERT(focusEditor, return 0);
     return focusEditor;
 }
 
diff --git a/src/plugins/snippets/snippetswindow.cpp b/src/plugins/snippets/snippetswindow.cpp
index d549a06cf7f708272343e6716ba2d74c532e045a..866e75359354c9bb2f60e1375c1b614b3ff7c48d 100644
--- a/src/plugins/snippets/snippetswindow.cpp
+++ b/src/plugins/snippets/snippetswindow.cpp
@@ -243,7 +243,7 @@ void SnippetsWindow::showInputWidget(bool canceled, const QString &value)
     } else {
         QString desc = m_currentSnippet->argumentDescription(m_requiredArgs.first());
         QString def = m_currentSnippet->argumentDefault(m_requiredArgs.first());
-        foreach(QString arg, m_args) {
+        foreach (const QString &arg, m_args) {
             desc = desc.arg(arg);
             def = def.arg(arg);
         }
diff --git a/src/plugins/subversion/subversioneditor.cpp b/src/plugins/subversion/subversioneditor.cpp
index 82f8fd55513017e0f8175050be605d227e52e4cc..3552c0f9b490298b5221cfed484f7496ab0e3ffe 100644
--- a/src/plugins/subversion/subversioneditor.cpp
+++ b/src/plugins/subversion/subversioneditor.cpp
@@ -32,9 +32,11 @@
 ***************************************************************************/
 
 #include "subversioneditor.h"
+
 #include "annotationhighlighter.h"
 #include "subversionconstants.h"
 
+#include <utils/qtcassert.h>
 #include <vcsbase/diffhighlighter.h>
 
 #include <QtCore/QDebug>
@@ -49,8 +51,8 @@ SubversionEditor::SubversionEditor(const VCSBase::VCSBaseEditorParameters *type,
     m_changeNumberPattern(QLatin1String("^\\d+$")),
     m_revisionNumberPattern(QLatin1String("^r\\d+$"))
 {
-    Q_ASSERT(m_changeNumberPattern.isValid());
-    Q_ASSERT(m_revisionNumberPattern.isValid());
+    QTC_ASSERT(m_changeNumberPattern.isValid(), return);
+    QTC_ASSERT(m_revisionNumberPattern.isValid(), return);
 }
 
 QSet<QString> SubversionEditor::annotationChanges() const
@@ -61,11 +63,11 @@ QSet<QString> SubversionEditor::annotationChanges() const
         return changes;
     // Hunt for first change number in annotation: "<change>:"
     QRegExp r(QLatin1String("^(\\d+):"));
-    Q_ASSERT(r.isValid());
+    QTC_ASSERT(r.isValid(), return changes);
     if (r.indexIn(txt) != -1) {
         changes.insert(r.cap(1));
         r.setPattern(QLatin1String("\n(\\d+):"));
-        Q_ASSERT(r.isValid());
+        QTC_ASSERT(r.isValid(), return changes);
         int pos = 0;
         while ((pos = r.indexIn(txt, pos)) != -1) {
             pos += r.matchedLength();
@@ -108,7 +110,7 @@ QString SubversionEditor::changeUnderCursor(const QTextCursor &c) const
 VCSBase::DiffHighlighter *SubversionEditor::createDiffHighlighter() const
 {
     const QRegExp filePattern(QLatin1String("^[-+][-+][-+] .*|^Index: .*|^==*$"));
-    Q_ASSERT(filePattern.isValid());
+    QTC_ASSERT(filePattern.isValid(), /**/);
     return new VCSBase::DiffHighlighter(filePattern);
 }
 
diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp
index a24bb7d3d06bbb0e652143e6a73cc134332f97a1..069299138060962ca6bd6bd3233dcfcdc607ecf3 100644
--- a/src/plugins/subversion/subversionplugin.cpp
+++ b/src/plugins/subversion/subversionplugin.cpp
@@ -56,6 +56,7 @@
 #include <coreplugin/actionmanager/actionmanagerinterface.h>
 #include <coreplugin/editormanager/editormanager.h>
 #include <projectexplorer/ProjectExplorerInterfaces>
+#include <utils/qtcassert.h>
 
 #include <QtCore/qplugin.h>
 #include <QtCore/QDebug>
@@ -194,7 +195,7 @@ SubversionPlugin::~SubversionPlugin()
     }
 
     if (!m_editorFactories.empty()) {
-        foreach(Core::IEditorFactory* pf, m_editorFactories)
+        foreach (Core::IEditorFactory* pf, m_editorFactories)
             removeObject(pf);
         qDeleteAll(m_editorFactories);
         m_editorFactories.clear();
@@ -504,7 +505,7 @@ SubversionSubmitEditor *SubversionPlugin::openSubversionSubmitEditor(const QStri
 {
     Core::IEditor *editor = m_coreInstance->editorManager()->openEditor(fileName, QLatin1String(Constants::SUBVERSIONCOMMITEDITOR_KIND));
     SubversionSubmitEditor *submitEditor = qobject_cast<SubversionSubmitEditor*>(editor);
-    Q_ASSERT(submitEditor);
+    QTC_ASSERT(submitEditor, /**/);
     // The actions are for some reason enabled by the context switching
     // mechanism. Disable them correctly.
     m_submitDiffAction->setEnabled(false);
@@ -579,9 +580,8 @@ void SubversionPlugin::revertCurrentFile()
 
     Core::FileManager *fm = m_coreInstance->fileManager();
     QList<Core::IFile *> files = fm->managedFiles(file);
-    foreach (Core::IFile *file, files) {
+    foreach (Core::IFile *file, files)
         fm->blockFileChange(file);
-    }
 
     // revert
     args.clear();
@@ -726,7 +726,7 @@ QStringList SubversionPlugin::parseStatusOutput(const QString &output) const
     QStringList changeSet;
     const QString newLine = QString(QLatin1Char('\n'));
     const QStringList list = output.split(newLine, QString::SkipEmptyParts);
-    foreach (const QString& l, list) {
+    foreach (const QString &l, list) {
         QString line(l.trimmed());
         if (line.startsWith(QLatin1Char('A')) || line.startsWith(QLatin1Char('D'))
             || line.startsWith(QLatin1Char('M')))
@@ -982,7 +982,7 @@ Core::IEditor * SubversionPlugin::showOutputInEditor(const QString& title, const
                                                      QTextCodec *codec)
 {
     const VCSBase::VCSBaseEditorParameters *params = findType(editorType);
-    Q_ASSERT(params);
+    QTC_ASSERT(params, return 0);
     const QString kind = QLatin1String(params->kind);
     if (Subversion::Constants::debug)
         qDebug() << "SubversionPlugin::showOutputInEditor" << title << kind <<  "Size= " << output.size() <<  " Type=" << editorType << debugCodec(codec);
@@ -1016,13 +1016,13 @@ void SubversionPlugin::setSettings(const SubversionSettings &s)
 
 Core::ICore *SubversionPlugin::coreInstance()
 {
-    Q_ASSERT(m_coreInstance);
+    QTC_ASSERT(m_coreInstance, return 0);
     return m_coreInstance;
 }
 
 SubversionPlugin *SubversionPlugin::subversionPluginInstance()
 {
-    Q_ASSERT(m_subversionPluginInstance);
+    QTC_ASSERT(m_subversionPluginInstance, m_subversionPluginInstance);
     return m_subversionPluginInstance;
 }
 
diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp
index 81427e7024aa4509e4e156274584ef773499b437..3758b1332789b5cbfaa59ea5efe5aa96cf1abab2 100644
--- a/src/plugins/texteditor/basetextdocument.cpp
+++ b/src/plugins/texteditor/basetextdocument.cpp
@@ -45,8 +45,9 @@
 
 #ifndef TEXTEDITOR_STANDALONE
 #include <utils/reloadpromptutils.h>
-#include "coreplugin/icore.h"
+#include <coreplugin/icore.h>
 #endif
+#include <utils/qtcassert.h>
 
 using namespace TextEditor;
 
@@ -236,7 +237,7 @@ bool BaseTextDocument::open(const QString &fileName)
             m_document->setPlainText(text);
         m_document->setUndoRedoEnabled(true);
         TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(m_document->documentLayout());
-        Q_ASSERT(documentLayout);
+        QTC_ASSERT(documentLayout, return true);
         documentLayout->lastSaveRevision = 0;
         m_document->setModified(false);
         emit titleChanged(title);
@@ -247,7 +248,7 @@ bool BaseTextDocument::open(const QString &fileName)
 
 void BaseTextDocument::reload(QTextCodec *codec)
 {
-    Q_ASSERT(codec);
+    QTC_ASSERT(codec, return);
     m_codec = codec;
     reload();
 }
@@ -255,9 +256,8 @@ void BaseTextDocument::reload(QTextCodec *codec)
 void BaseTextDocument::reload()
 {
     emit aboutToReload();
-    if (open(m_fileName)) {
+    if (open(m_fileName))
         emit reloaded();
-    }
 }
 
 void BaseTextDocument::modified(Core::IFile::ReloadBehavior *behavior)
@@ -302,6 +302,18 @@ void BaseTextDocument::setSyntaxHighlighter(QSyntaxHighlighter *highlighter)
     m_highlighter->setDocument(m_document);
 }
 
+
+
+void BaseTextDocument::cleanWhitespace()
+{
+    QTextCursor cursor(m_document);
+    cursor.beginEditBlock();
+    cleanWhitespace(cursor, true);
+    if (m_storageSettings.m_addFinalNewLine)
+        ensureFinalNewLine(cursor);
+    cursor.endEditBlock();
+}
+
 void BaseTextDocument::cleanWhitespace(QTextCursor& cursor, bool inEntireDocument)
 {
 
diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h
index ee8e5eb427a14da649ff631f18df220a6cc1b989..b945129c474a95e83b1052f204b1c57380bb575c 100644
--- a/src/plugins/texteditor/basetextdocument.h
+++ b/src/plugins/texteditor/basetextdocument.h
@@ -118,6 +118,8 @@ public:
 
     void reload(QTextCodec *codec);
 
+    void cleanWhitespace();
+
 signals:
     void titleChanged(QString title);
     void changed();
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 82a4201b264576bdc79dacc33b6488bc32695357..db5413c3446c8370c5d99db1a79d0c380508c424 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -53,6 +53,7 @@
 #include <aggregation/aggregate.h>
 #endif
 #include <utils/linecolumnlabel.h>
+#include <utils/qtcassert.h>
 
 #include <QtCore/QCoreApplication>
 #include <QtCore/QTextCodec>
@@ -415,10 +416,10 @@ UserCanceled:
 
 bool DocumentMarker::addMark(TextEditor::ITextMark *mark, int line)
 {
-    Q_ASSERT(line >= 1);
+    QTC_ASSERT(line >= 1, return false);
     int blockNumber = line - 1;
     TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(document->documentLayout());
-    Q_ASSERT(documentLayout);
+    QTC_ASSERT(documentLayout, return false);
     QTextBlock block = document->findBlockByNumber(blockNumber);
 
     if (block.isValid()) {
@@ -436,7 +437,7 @@ bool DocumentMarker::addMark(TextEditor::ITextMark *mark, int line)
 
 TextEditor::TextMarks DocumentMarker::marksAt(int line) const
 {
-    Q_ASSERT(line >= 1);
+    QTC_ASSERT(line >= 1, return TextMarks());
     int blockNumber = line - 1;
     QTextBlock block = document->findBlockByNumber(blockNumber);
 
@@ -531,9 +532,9 @@ void BaseTextEditor::selectEncoding()
 
 void DocumentMarker::updateMark(ITextMark *mark)
 {
-    TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(document->documentLayout());
-    Q_ASSERT(documentLayout);
     Q_UNUSED(mark);
+    TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(document->documentLayout());
+    QTC_ASSERT(documentLayout, return);
     documentLayout->requestUpdate();
 }
 
@@ -684,6 +685,10 @@ void BaseTextEditor::selectBlockDown()
 }
 
 
+void BaseTextEditor::cleanWhitespace()
+{
+        d->m_document->cleanWhitespace();
+}
 
 void BaseTextEditor::keyPressEvent(QKeyEvent *e)
 {
@@ -857,7 +862,7 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
             }
 #if 0
             TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(document()->documentLayout());
-            Q_ASSERT(documentLayout);
+            QTC_ASSERT(documentLayout, return);
             documentLayout->requestUpdate(); // a bit drastic
             e->accept();
 #endif
@@ -1628,13 +1633,27 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
     QPainter painter(viewport());
     QTextDocument *doc = document();
     TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(doc->documentLayout());
-    Q_ASSERT(documentLayout);
+    QTC_ASSERT(documentLayout, return);
 
     QPointF offset(contentOffset());
 
     QRect er = e->rect();
     QRect viewportRect = viewport()->rect();
 
+    const QColor baseColor = palette().base().color();
+    const int blendBase = (baseColor.value() > 128) ? 0 : 255;
+    // Darker backgrounds may need a bit more contrast
+    // (this calculation is temporary solution until we have a setting for this color)
+    const int blendFactor = (baseColor.value() > 128) ? 8 : 16;
+    const QColor blendColor(
+        (blendBase * blendFactor + baseColor.blue() * (256 - blendFactor)) / 256,
+        (blendBase * blendFactor + baseColor.green() * (256 - blendFactor)) / 256,
+        (blendBase * blendFactor + baseColor.blue() * (256 - blendFactor)) / 256);
+    if (d->m_visibleWrapColumn > 0) {
+        qreal lineX = fontMetrics().averageCharWidth() * d->m_visibleWrapColumn + offset.x() + 4;
+        painter.fillRect(QRectF(lineX, 0, viewportRect.width() - lineX, viewportRect.height()), blendColor);
+    }
+
     // keep right margin clean from full-width selection
     int maxX = offset.x() + qMax((qreal)viewportRect.width(), documentLayout->documentSize().width())
                - doc->documentMargin();
@@ -1647,7 +1666,6 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
 
     QAbstractTextDocumentLayout::PaintContext context = getPaintContext();
 
-
     if (!d->m_findScope.isNull()) {
         QAbstractTextDocumentLayout::Selection selection;
         selection.format.setBackground(d->m_searchScopeFormat.background());
@@ -1672,20 +1690,6 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
         blockSelection->lastColumn = qMax(columnA, columnB) + d->m_blockSelectionExtraX;
     }
 
-    const QColor baseColor = palette().base().color();
-    const int blendBase = (baseColor.value() > 128) ? 0 : 255;
-    // Darker backgrounds may need a bit more contrast
-    // (this calculation is temporary solution until we have a setting for this color)
-    const int blendFactor = (baseColor.value() > 128) ? 8 : 16;
-    const QColor blendColor(
-        (blendBase * blendFactor + baseColor.blue() * (256 - blendFactor)) / 256,
-        (blendBase * blendFactor + baseColor.green() * (256 - blendFactor)) / 256,
-        (blendBase * blendFactor + baseColor.blue() * (256 - blendFactor)) / 256);
-    if (d->m_visibleWrapColumn > 0) {
-        qreal lineX = fontMetrics().averageCharWidth() * d->m_visibleWrapColumn + offset.x() + 4;
-        painter.fillRect(QRectF(lineX, 0, viewportRect.width() - lineX, viewportRect.height()), blendColor);
-    }
-
     QTextBlock visibleCollapsedBlock;
     QPointF visibleCollapsedBlockOffset;
 
@@ -2056,7 +2060,7 @@ void BaseTextEditor::slotModificationChanged(bool m)
 
     QTextDocument *doc = document();
     TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(doc->documentLayout());
-    Q_ASSERT(documentLayout);
+    QTC_ASSERT(documentLayout, return);
     int oldLastSaveRevision = documentLayout->lastSaveRevision;
     documentLayout->lastSaveRevision = doc->revision();
 
@@ -2114,7 +2118,7 @@ void BaseTextEditor::extraAreaPaintEvent(QPaintEvent *e)
 {
     QTextDocument *doc = document();
     TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(doc->documentLayout());
-    Q_ASSERT(documentLayout);
+    QTC_ASSERT(documentLayout, return);
 
     QPalette pal = d->m_extraArea->palette();
     pal.setCurrentColorGroup(QPalette::Active);
@@ -2613,7 +2617,7 @@ void BaseTextEditor::ensureCursorVisible()
 void BaseTextEditor::toggleBlockVisible(const QTextBlock &block)
 {
     TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(document()->documentLayout());
-    Q_ASSERT(documentLayout);
+    QTC_ASSERT(documentLayout, return);
 
     bool visible = block.next().isVisible();
     TextBlockUserData::doCollapse(block, !visible);
@@ -2712,7 +2716,7 @@ void BaseTextEditor::handleHomeKey(bool anchor)
 void BaseTextEditor::handleBackspaceKey()
 {
     QTextCursor cursor = textCursor();
-    Q_ASSERT(!cursor.hasSelection());
+    QTC_ASSERT(!cursor.hasSelection(), return);
 
     const TextEditor::TabSettings &tabSettings = d->m_document->tabSettings();
     QTextBlock currentBlock = cursor.block();
@@ -2751,7 +2755,9 @@ void BaseTextEditor::handleBackspaceKey()
 void BaseTextEditor::format()
 {
     QTextCursor cursor = textCursor();
+    cursor.beginEditBlock();
     indent(document(), cursor, QChar::Null);
+    cursor.endEditBlock();
 }
 
 void BaseTextEditor::unCommentSelection()
@@ -3272,7 +3278,7 @@ void BaseTextEditor::setIfdefedOutBlocks(const QList<BaseTextEditor::BlockRange>
 {
     QTextDocument *doc = document();
     TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(doc->documentLayout());
-    Q_ASSERT(documentLayout);
+    QTC_ASSERT(documentLayout, return);
 
     bool needUpdate = false;
 
@@ -3317,18 +3323,15 @@ void BaseTextEditor::collapse()
 {
     QTextDocument *doc = document();
     TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(doc->documentLayout());
-    Q_ASSERT(documentLayout);
+    QTC_ASSERT(documentLayout, return);
     QTextBlock block = textCursor().block();
-    qDebug() << "collapse at block" << block.blockNumber();
     while (block.isValid()) {
-        qDebug() << "test block" << block.blockNumber();
         if (TextBlockUserData::canCollapse(block) && block.next().isVisible()) {
             if ((block.next().userState()) >> 8 <= (textCursor().block().userState() >> 8))
                 break;
         }
         block = block.previous();
     }
-    qDebug() << "found" << block.blockNumber();
     if (block.isValid()) {
         TextBlockUserData::doCollapse(block, false);
         d->moveCursorVisible();
@@ -3341,7 +3344,7 @@ void BaseTextEditor::expand()
 {
     QTextDocument *doc = document();
     TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(doc->documentLayout());
-    Q_ASSERT(documentLayout);
+    QTC_ASSERT(documentLayout, return);
     QTextBlock block = textCursor().block();
     while (block.isValid() && !block.isVisible())
         block = block.previous();
@@ -3355,7 +3358,7 @@ void BaseTextEditor::unCollapseAll()
 {
     QTextDocument *doc = document();
     TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(doc->documentLayout());
-    Q_ASSERT(documentLayout);
+    QTC_ASSERT(documentLayout, return);
 
     QTextBlock block = doc->firstBlock();
     bool makeVisible = true;
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index 40454a9c7d430dc6b188567843a7e13323f98f88..1219439fc986264c6e55230cac59b0b00c507a4e 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -329,6 +329,8 @@ public slots:
     void selectBlockUp();
     void selectBlockDown();
 
+    void cleanWhitespace();
+
 signals:
     void changed();
 
diff --git a/src/plugins/texteditor/basetextmark.cpp b/src/plugins/texteditor/basetextmark.cpp
index 07af35771874b9635baf5a08d6e550b2633717c8..d3ec41eb293f5d8409bd72a61b80eb6a2db01a69 100644
--- a/src/plugins/texteditor/basetextmark.cpp
+++ b/src/plugins/texteditor/basetextmark.cpp
@@ -60,9 +60,8 @@ void BaseTextMark::init()
     Core::EditorManager *em = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->editorManager();
     connect(em, SIGNAL(editorOpened(Core::IEditor *)), this, SLOT(editorOpened(Core::IEditor *)));
 
-    foreach(Core::IEditor *editor, em->openedEditors()) {
+    foreach (Core::IEditor *editor, em->openedEditors())
         editorOpened(editor);
-    }
 }
 
 void BaseTextMark::editorOpened(Core::IEditor *editor)
@@ -132,7 +131,6 @@ void BaseTextMark::moveMark(const QString & /* filename */, int /* line */)
     delete m_internalMark;
     m_internalMark = 0;
 
-    foreach(Core::IEditor *editor, em->openedEditors()) {
+    foreach (Core::IEditor *editor, em->openedEditors())
         editorOpened(editor);
-    }
 }
diff --git a/src/plugins/texteditor/codecselector.cpp b/src/plugins/texteditor/codecselector.cpp
index a8ff2e68bc3721e6f2feb9118400f3f5416b6038..3dcdf9f37353b32cbbef8ae42061e286b877f0b2 100644
--- a/src/plugins/texteditor/codecselector.cpp
+++ b/src/plugins/texteditor/codecselector.cpp
@@ -87,15 +87,15 @@ CodecSelector::CodecSelector(QWidget *parent, BaseTextDocument *doc)
     QList<int> mibs = QTextCodec::availableMibs();
     qSort(mibs);
     QList<int> sortedMibs;
-    foreach(int mib, mibs)
+    foreach (int mib, mibs)
         if (mib >= 0)
             sortedMibs += mib;
-    foreach(int mib, mibs)
+    foreach (int mib, mibs)
         if (mib < 0)
             sortedMibs += mib;
 
     int currentIndex = -1;
-    foreach(int mib, sortedMibs) {
+    foreach (int mib, sortedMibs) {
         QTextCodec *c = QTextCodec::codecForMib(mib);
         if (!buf.isEmpty()) {
 
@@ -109,9 +109,8 @@ CodecSelector::CodecSelector(QWidget *parent, BaseTextDocument *doc)
                 continue;
         }
         QString names = QString::fromLatin1(c->name());
-        foreach(QByteArray alias, c->aliases()) {
+        foreach (QByteArray alias, c->aliases())
             names += QLatin1String(" / ") + QString::fromLatin1(alias);
-        }
         if (doc->codec() == c)
             currentIndex = encodings.count();
         encodings << names;
diff --git a/src/plugins/texteditor/completionsupport.cpp b/src/plugins/texteditor/completionsupport.cpp
index 38c017040e94aa356ebea4357aeb6f424280d06a..e7f6a5879a07f3d0ce22637596b3c06893f9c6a5 100644
--- a/src/plugins/texteditor/completionsupport.cpp
+++ b/src/plugins/texteditor/completionsupport.cpp
@@ -37,6 +37,7 @@
 
 #include <coreplugin/icore.h>
 #include <texteditor/itexteditable.h>
+#include <utils/qtcassert.h>
 
 #include <QString>
 #include <QList>
@@ -103,7 +104,7 @@ void CompletionSupport::autoComplete(ITextEditable *editor, bool forced)
         m_startPosition = m_completionCollector->startCompletion(editor);
         completionItems = getCompletions();
 
-        Q_ASSERT(m_startPosition != -1 || completionItems.size() == 0);
+        QTC_ASSERT(m_startPosition != -1 || completionItems.size() == 0, return);
 
         if (completionItems.isEmpty()) {
             cleanupCompletions();
diff --git a/src/plugins/texteditor/completionwidget.cpp b/src/plugins/texteditor/completionwidget.cpp
index ae296dca55731b57873029ea16c2b03c1b1866ea..be2a2091c3728c394b662b17a436e66ecfe21f53 100644
--- a/src/plugins/texteditor/completionwidget.cpp
+++ b/src/plugins/texteditor/completionwidget.cpp
@@ -36,6 +36,7 @@
 #include "icompletioncollector.h"
 
 #include <texteditor/itexteditable.h>
+#include <utils/qtcassert.h>
 
 #include <QtCore/QEvent>
 #include <QtGui/QKeyEvent>
@@ -107,7 +108,7 @@ CompletionWidget::CompletionWidget(CompletionSupport *support, ITextEditable *ed
       m_model(0),
       m_support(support)
 {
-    Q_ASSERT(m_editorWidget);
+    QTC_ASSERT(m_editorWidget, return);
 
     setUniformItemSizes(true);
     setSelectionBehavior(QAbstractItemView::SelectItems);
diff --git a/src/plugins/texteditor/fontsettings.cpp b/src/plugins/texteditor/fontsettings.cpp
index bbde495f8dd3662e4b611af659935c83c202997e..28181654174c776f3fada62930b05c959be9287b 100644
--- a/src/plugins/texteditor/fontsettings.cpp
+++ b/src/plugins/texteditor/fontsettings.cpp
@@ -34,6 +34,8 @@
 #include "fontsettings.h"
 #include "fontsettingspage.h"
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/QSettings>
 #include <QtGui/QTextCharFormat>
 
@@ -133,11 +135,13 @@ bool Format::equals(const Format &f) const
     return m_foreground ==  f.m_foreground && m_background == f.m_background &&
            m_bold == f.m_bold && m_italic == f.m_italic;
 }
+
 // -- FontSettings
-FontSettings::FontSettings(const FormatDescriptions & /* fd */) :
+FontSettings::FontSettings(const FormatDescriptions &fd) :
     m_family(defaultFixedFontFamily()),
     m_fontSize(DEFAULT_FONT_SIZE)
 {
+    Q_UNUSED(fd);
 }
 
 void FontSettings::clear()
@@ -152,7 +156,7 @@ void FontSettings::toSettings(const QString &category,
                               QSettings *s) const
 {
     const int numFormats = m_formats.size();
-    Q_ASSERT(descriptions.size() == numFormats);
+    QTC_ASSERT(descriptions.size() == numFormats, /**/);
     s->beginGroup(category);
     if (m_family != defaultFixedFontFamily() || s->contains(QLatin1String(fontFamilyKey)))
         s->setValue(QLatin1String(fontFamilyKey), m_family);
diff --git a/src/plugins/texteditor/tabsettings.cpp b/src/plugins/texteditor/tabsettings.cpp
index f87ab2ac8cf27efb0fb792aa948234b3609c3a88..19145a7cd9748d6e3860db950719fda621c7d8dd 100644
--- a/src/plugins/texteditor/tabsettings.cpp
+++ b/src/plugins/texteditor/tabsettings.cpp
@@ -132,7 +132,7 @@ bool TabSettings::isIndentationClean(const QString &text) const
 
         if (c == QLatin1Char(' ')) {
             ++spaceCount;
-            if (spaceCount == m_tabSize)
+            if (!m_spacesForTabs && spaceCount == m_tabSize)
                 return false;
         } else if (c == QLatin1Char('\t')) {
             if (m_spacesForTabs || spaceCount != m_indentSize)
diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp
index 635f96545769d0e36a03dadf3de5a3544d2882b8..12fc7d1fac5a3d2b55f6c76d412e008238a86d75 100644
--- a/src/plugins/texteditor/texteditoractionhandler.cpp
+++ b/src/plugins/texteditor/texteditoractionhandler.cpp
@@ -42,6 +42,7 @@
 #include <coreplugin/uniqueidmanager.h>
 #include <coreplugin/actionmanager/actionmanagerinterface.h>
 #include <coreplugin/editormanager/editormanager.h>
+#include <utils/qtcassert.h>
 
 #include <QtCore/QSet>
 #include <QtCore/QtDebug>
@@ -62,7 +63,7 @@ TextEditorActionHandler::TextEditorActionHandler(Core::ICore *core,
 {
     m_undoAction = m_redoAction = m_copyAction = m_cutAction = m_pasteAction
                  = m_selectAllAction = m_gotoAction = m_printAction = m_formatAction
-                 = m_visualizeWhitespaceAction = m_textWrappingAction
+                 = m_visualizeWhitespaceAction = m_cleanWhitespaceAction = m_textWrappingAction
                  = m_unCommentSelectionAction = m_unCollapseAllAction
                  = m_collapseAction = m_expandAction
                  = m_deleteLineAction = m_selectEncodingAction
@@ -127,17 +128,23 @@ void TextEditorActionHandler::createActions()
     connect(m_formatAction, SIGNAL(triggered(bool)), this, SLOT(formatAction()));
 
 
-    m_visualizeWhitespaceAction = new QAction(tr("Visualize &Whitespace"), this);
+    m_visualizeWhitespaceAction = new QAction(tr("&Visualize Whitespace"), this);
     m_visualizeWhitespaceAction->setCheckable(true);
     command = am->registerAction(m_visualizeWhitespaceAction,
                                                  TextEditor::Constants::VISUALIZE_WHITESPACE, m_contextId);
 #ifndef Q_OS_MAC
     command->setDefaultKeySequence(QKeySequence(tr("Ctrl+E, Ctrl+V")));
 #endif
-
     advancedMenu->addAction(command);
     connect(m_visualizeWhitespaceAction, SIGNAL(triggered(bool)), this, SLOT(setVisualizeWhitespace(bool)));
 
+    m_cleanWhitespaceAction = new QAction(tr("Clean Whitespace"), this);
+    command = am->registerAction(m_cleanWhitespaceAction,
+                                 TextEditor::Constants::CLEAN_WHITESPACE, m_contextId);
+
+    advancedMenu->addAction(command);
+    connect(m_cleanWhitespaceAction, SIGNAL(triggered()), this, SLOT(cleanWhitespace()));
+
     m_textWrappingAction = new QAction(tr("Enable Text &Wrapping"), this);
     m_textWrappingAction->setCheckable(true);
     command = am->registerAction(m_textWrappingAction,
@@ -284,6 +291,7 @@ void TextEditorActionHandler::updateActions(UpdateMode um)
     m_visualizeWhitespaceAction->setEnabled(um != NoEditor);
     if (m_currentEditor)
         m_visualizeWhitespaceAction->setChecked(m_currentEditor->displaySettings().m_visualizeWhitespace);
+    m_cleanWhitespaceAction->setEnabled(um != NoEditor);
     if (m_textWrappingAction) {
         m_textWrappingAction->setEnabled(um != NoEditor);
         if (m_currentEditor)
@@ -316,46 +324,10 @@ void TextEditorActionHandler::updateCopyAction()
         m_copyAction->setEnabled(hasCopyableText);
 }
 
-void TextEditorActionHandler::undoAction()
-{
-    if (m_currentEditor)
-        m_currentEditor->undo();
-}
-
-void TextEditorActionHandler::redoAction()
-{
-    if (m_currentEditor)
-        m_currentEditor->redo();
-}
-
-void TextEditorActionHandler::copyAction()
-{
-    if (m_currentEditor)
-        m_currentEditor->copy();
-}
-
-void TextEditorActionHandler::cutAction()
-{
-    if (m_currentEditor)
-        m_currentEditor->cut();
-}
-
-void TextEditorActionHandler::pasteAction()
-{
-    if (m_currentEditor)
-        m_currentEditor->paste();
-}
-
-void TextEditorActionHandler::selectAllAction()
-{
-    if (m_currentEditor)
-        m_currentEditor->selectAll();
-}
-
 void TextEditorActionHandler::gotoAction()
 {
     QuickOpen::QuickOpenManager *quickopen = QuickOpen::QuickOpenManager::instance();
-    Q_ASSERT(quickopen);
+    QTC_ASSERT(quickopen, return);
     QString shortcut = TextEditorPlugin::instance()->lineNumberFilter()->shortcutString();
     quickopen->show(shortcut + " <line number>", 2, 13);
 }
@@ -366,13 +338,6 @@ void TextEditorActionHandler::printAction()
         m_currentEditor->print(m_core->printer());
 }
 
-void TextEditorActionHandler::formatAction()
-{
-    if (m_currentEditor)
-        m_currentEditor->format();
-}
-
-
 void TextEditorActionHandler::setVisualizeWhitespace(bool checked)
 {
     if (m_currentEditor) {
@@ -402,6 +367,15 @@ void TextEditorActionHandler::setTextWrapping(bool checked)
         m_currentEditor->funcname2 ();\
 }
 
+
+FUNCTION2(undoAction, undo)
+FUNCTION2(redoAction, redo)
+FUNCTION2(copyAction, copy)
+FUNCTION2(cutAction, cut)
+FUNCTION2(pasteAction, paste)
+FUNCTION2(formatAction, format)
+FUNCTION2(selectAllAction, selectAll)
+FUNCTION(cleanWhitespace)
 FUNCTION(unCommentSelection)
 FUNCTION(deleteLine)
 FUNCTION(unCollapseAll)
diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h
index 9a8c7b9f57c89ceb4a6bd1e1971b1c06bce7ed61..520ae26ddf6618e0a09d18cc80f8751592901fbc 100644
--- a/src/plugins/texteditor/texteditoractionhandler.h
+++ b/src/plugins/texteditor/texteditoractionhandler.h
@@ -100,6 +100,7 @@ private slots:
     void printAction();
     void formatAction();
     void setVisualizeWhitespace(bool);
+    void cleanWhitespace();
     void setTextWrapping(bool);
     void unCommentSelection();
     void unCollapseAll();
@@ -128,6 +129,7 @@ private:
     QAction *m_printAction;
     QAction *m_formatAction;
     QAction *m_visualizeWhitespaceAction;
+    QAction *m_cleanWhitespaceAction;
     QAction *m_textWrappingAction;
     QAction *m_unCommentSelectionAction;
     QAction *m_unCollapseAllAction;
diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h
index 9ac9fdff0e4c368ecb3d43f6ad13da8f86f7660d..192a07c257e86ec089721fc19f27edbfc3b857b7 100644
--- a/src/plugins/texteditor/texteditorconstants.h
+++ b/src/plugins/texteditor/texteditorconstants.h
@@ -40,6 +40,7 @@ namespace Constants {
 const char * const C_TEXTEDITOR          = "Text Editor";
 const char * const COMPLETE_THIS         = "TextEditor.CompleteThis";
 const char * const VISUALIZE_WHITESPACE  = "TextEditor.VisualizeWhitespace";
+const char * const CLEAN_WHITESPACE      = "TextEditor.CleanWhitespace";
 const char * const TEXT_WRAPPING         = "TextEditor.TextWrapping";
 const char * const UN_COMMENT_SELECTION  = "TextEditor.UnCommentSelection";
 const char * const COLLAPSE              = "TextEditor.Collapse";
diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp
index f50d6dacc964fc12c187d1d90cce7fb61a18266f..ff102b531175d02394200b8d4e74c076fda2ef4f 100644
--- a/src/plugins/texteditor/texteditorplugin.cpp
+++ b/src/plugins/texteditor/texteditorplugin.cpp
@@ -50,6 +50,7 @@
 #include <coreplugin/actionmanager/icommand.h>
 #include <coreplugin/editormanager/editormanager.h>
 #include <texteditor/texteditoractionhandler.h>
+#include <utils/qtcassert.h>
 
 #include <QtCore/qplugin.h>
 #include <QtGui/QShortcut>
@@ -67,7 +68,7 @@ TextEditorPlugin::TextEditorPlugin() :
     m_editorFactory(0),
     m_lineNumberFilter(0)
 {
-    Q_ASSERT(!m_instance);
+    QTC_ASSERT(!m_instance, return);
     m_instance = this;
 }
 
diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp
index 3350e2bee16779c3ce739679aa13d8c9dc5e3c14..20b4e1037fe1929c329204e7db98265376a378b3 100644
--- a/src/plugins/texteditor/texteditorsettings.cpp
+++ b/src/plugins/texteditor/texteditorsettings.cpp
@@ -41,6 +41,8 @@
 #include "texteditorconstants.h"
 #include "texteditorplugin.h"
 
+#include <utils/qtcassert.h>
+
 #include <QApplication>
 
 using namespace TextEditor;
@@ -52,7 +54,7 @@ TextEditorSettings::TextEditorSettings(Internal::TextEditorPlugin *plugin,
                                        QObject *parent)
     : QObject(parent)
 {
-    Q_ASSERT(!m_instance);
+    QTC_ASSERT(!m_instance, return);
     m_instance = this;
 
     ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
diff --git a/src/plugins/vcsbase/diffhighlighter.cpp b/src/plugins/vcsbase/diffhighlighter.cpp
index 60f219842fc67dc93e9611522f514a8c02722b33..f5fe9fff92dd03ae0b9f1f751800856f6c054356 100644
--- a/src/plugins/vcsbase/diffhighlighter.cpp
+++ b/src/plugins/vcsbase/diffhighlighter.cpp
@@ -33,6 +33,8 @@
 
 #include "diffhighlighter.h"
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/QDebug>
 #include <QtCore/QtAlgorithms>
 #include <QtCore/QRegExp>
@@ -67,7 +69,7 @@ DiffHighlighterPrivate::DiffHighlighterPrivate(const QRegExp &filePattern) :
     m_diffInIndicator(QLatin1Char('+')),
     m_diffOutIndicator(QLatin1Char('-'))
 {
-    Q_ASSERT(filePattern.isValid());
+    QTC_ASSERT(filePattern.isValid(), /**/);
 }
 
 DiffFormats DiffHighlighterPrivate::analyzeLine(const QString &text) const
diff --git a/src/tools/makespy/main.cpp b/src/tools/makespy/main.cpp
index 9cce394f0a0f4f361fae440db8b8dec057863500..e8ebd7dea098bb38ed2e791c4be3f734275da6e8 100644
--- a/src/tools/makespy/main.cpp
+++ b/src/tools/makespy/main.cpp
@@ -108,7 +108,6 @@ void MakeProcess::handleOutput()
     }
 }
 
-
 void MakeProcess::handleMakeLine(const QString &line)
 {
     int pos1 = line.indexOf('`');
diff --git a/tests/auto/profilereader/sync b/tests/auto/profilereader/sync
index f0950addcc8806cbd4f7b40ad22d6a779d7c7608..9dcbc91dcae545259fa8746702403c34d8e83609 100755
--- a/tests/auto/profilereader/sync
+++ b/tests/auto/profilereader/sync
@@ -53,7 +53,7 @@ while ( @ARGV ) {
     if ("$arg" eq "-h" || "$arg" eq "-help" || "$arg" eq "--help" || "$arg" eq "?" || "$arg" eq "/?" || "$arg" eq "-?") {
 	showUsage();
 	exit(0);
-    } elsif("$arg" eq "-qtdir") {
+    } elsif ("$arg" eq "-qtdir") {
 	$qtSrcTree = shift @ARGV;
     } else {
 	print "Unknown option: $arg\n";
diff --git a/tests/manual/cplusplus/main.cpp b/tests/manual/cplusplus/main.cpp
index 234c9684a394c06e6f4b2f852af9ff1ae6de5851..fd3c730f41d5f9cccf9c88d193dfad2e03314d66 100644
--- a/tests/manual/cplusplus/main.cpp
+++ b/tests/manual/cplusplus/main.cpp
@@ -31,17 +31,17 @@
 **
 ***************************************************************************/
 
-#include <QFile>
+#include <AST.h>
+#include <Control.h>
+#include <Scope.h>
+#include <Semantic.h>
+#include <TranslationUnit.h>
+
+#include <QtCore/QFile>
 
 #include <cstdio>
 #include <cstdlib>
 
-#include <TranslationUnit.h>
-#include <Control.h>
-#include <AST.h>
-#include <Semantic.h>
-#include <Scope.h>
-
 int main(int, char *[])
 {
     Control control;