diff --git a/src/libs/qmljs/parser/gen-parser.sh b/src/libs/qmljs/parser/gen-parser.sh
index 7123511b2cacdab01d618dd75fb7449b30dc6c39..acd6a19ce7c56ae7a9bb556cea7df48081b8e7ae 100755
--- a/src/libs/qmljs/parser/gen-parser.sh
+++ b/src/libs/qmljs/parser/gen-parser.sh
@@ -2,7 +2,7 @@
 
 me=$(dirname $0)
 
-for i in $QTDIR/src/declarative/qml/parser/*.{h,cpp,pri}; do
+for i in $QTDIR/src/declarative/qml/parser/*.{g,h,cpp,pri}; do
     sed -f $me/cmd.sed $i > $me/$(echo $(basename $i) | sed s/qdeclarativejs/qmljs/)
 done
 
diff --git a/src/libs/qmljs/parser/qmljs.g b/src/libs/qmljs/parser/qmljs.g
index 90949d5710577247718a227ad6c824eca8a3e2ab..1d59d21f16a1dd5834483ae7402cadcade2b5b07 100644
--- a/src/libs/qmljs/parser/qmljs.g
+++ b/src/libs/qmljs/parser/qmljs.g
@@ -65,6 +65,7 @@
 %token T_PUBLIC "public"
 %token T_IMPORT "import"
 %token T_AS "as"
+%token T_ON "on"
 
 --- feed tokens
 %token T_FEED_UI_PROGRAM
@@ -653,18 +654,15 @@ case $rule_number: {
         node = makeAstNode<AST::UiImport>(driver->nodePool(), importIdLiteral->value);
         node->fileNameToken = loc(2);
     } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
-        QString text;
-        for (AST::UiQualifiedId *q = qualifiedId; q; q = q->next) {
-	   text += q->name->asString();
-           if (q->next) text += QLatin1String(".");
-        }
         node = makeAstNode<AST::UiImport>(driver->nodePool(), qualifiedId);
         node->fileNameToken = loc(2);
     }
 
     sym(1).Node = node;
 
-    if (! node) {
+    if (node) {
+        node->importToken = loc(1);
+    } else {
        diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
          QLatin1String("Expected a qualified name id or a string literal")));
 
@@ -773,6 +771,17 @@ case $rule_number: {
 } break;
 ./
 
+UiObjectMember: UiQualifiedId             T_ON UiQualifiedId  UiObjectInitializer ;
+/.
+case $rule_number: {
+    AST::UiObjectBinding *node = makeAstNode<AST::UiObjectBinding> (driver->nodePool(),
+      sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer);
+    node->colonToken = loc(2);
+    node->hasOnToken = true;
+    sym(1).Node = node;
+} break;
+./
+
 UiObjectMember: UiQualifiedId T_COLON Block ;
 /.case $rule_number:./
 
@@ -870,8 +879,8 @@ case $rule_number: {
 }   break;
 ./
 
-UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT T_IDENTIFIER T_SEMICOLON ;
+UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ;
 /.
 case $rule_number: {
     AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(4).sval, sym(6).sval);
@@ -885,8 +894,8 @@ case $rule_number: {
 }   break;
 ./
 
-UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_SEMICOLON ;
+UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ;
 /.
 case $rule_number: {
     AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval);
@@ -898,8 +907,8 @@ case $rule_number: {
 }   break;
 ./
 
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_SEMICOLON ;
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ;
 /.
 case $rule_number: {
     AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval);
@@ -913,8 +922,8 @@ case $rule_number: {
 }   break;
 ./
 
-UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_SEMICOLON ;
+UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_SEMICOLON ;
 /.
 case $rule_number: {
     AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval,
@@ -928,8 +937,8 @@ case $rule_number: {
 }   break;
 ./
 
-UiObjectMember: T_READONLY T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_READONLY T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_SEMICOLON ;
+UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_SEMICOLON ;
 /.
 case $rule_number: {
     AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
@@ -945,8 +954,8 @@ case $rule_number: {
 }   break;
 ./
 
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_SEMICOLON ;
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_SEMICOLON ;
 /.
 case $rule_number: {
     AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
@@ -1005,6 +1014,15 @@ case $rule_number: {
 }
 ./
 
+JsIdentifier: T_ON ;
+/.
+case $rule_number: {
+    QString s = QLatin1String(QmlJSGrammar::spell[T_ON]);
+    sym(1).sval = driver->intern(s.constData(), s.length());
+    break;
+}
+./
+
 --------------------------------------------------------------------------------------------------------
 -- Expressions
 --------------------------------------------------------------------------------------------------------
@@ -1086,6 +1104,9 @@ case $rule_number: {
     diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
     return false; // ### remove me
   }
+
+  loc(1).length = lexer->tokenLength();
+
   AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
   node->literalToken = loc(1);
   sym(1).Node = node;
@@ -1103,6 +1124,9 @@ case $rule_number: {
     diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
     return false;
   }
+
+  loc(1).length = lexer->tokenLength();
+
   AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
   node->literalToken = loc(1);
   sym(1).Node = node;
diff --git a/src/libs/qmljs/parser/qmljsparser.cpp b/src/libs/qmljs/parser/qmljsparser.cpp
index 5e12f8543cdf7da48afab1631c742ee057e8e31e..86b9903189c34298ea14be625b23634ea318b616 100644
--- a/src/libs/qmljs/parser/qmljsparser.cpp
+++ b/src/libs/qmljs/parser/qmljsparser.cpp
@@ -273,11 +273,6 @@ case 20: {
         node = makeAstNode<AST::UiImport>(driver->nodePool(), importIdLiteral->value);
         node->fileNameToken = loc(2);
     } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
-        QString text;
-        for (AST::UiQualifiedId *q = qualifiedId; q; q = q->next) {
-	   text += q->name->asString();
-           if (q->next) text += QLatin1String(".");
-        }
         node = makeAstNode<AST::UiImport>(driver->nodePool(), qualifiedId);
         node->fileNameToken = loc(2);
     }
@@ -571,6 +566,9 @@ case 76: {
     diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
     return false; // ### remove me
   }
+
+  loc(1).length = lexer->tokenLength();
+
   AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
   node->literalToken = loc(1);
   sym(1).Node = node;
@@ -582,6 +580,9 @@ case 77: {
     diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
     return false;
   }
+
+  loc(1).length = lexer->tokenLength();
+
   AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
   node->literalToken = loc(1);
   sym(1).Node = node;
diff --git a/src/libs/utils/wizard.cpp b/src/libs/utils/wizard.cpp
index 0149c882b6c6ddf69d33435b8285d8dc41e6a129..4489c95ca2b4951d33150401db2c2f0c12ff432f 100644
--- a/src/libs/utils/wizard.cpp
+++ b/src/libs/utils/wizard.cpp
@@ -290,8 +290,8 @@ public:
     WizardProgress *m_wizardProgress;
 };
 
-Wizard::Wizard(QWidget *parent) :
-    QWizard(parent), d_ptr(new WizardPrivate)
+Wizard::Wizard(QWidget *parent, Qt::WindowFlags flags) :
+    QWizard(parent, flags), d_ptr(new WizardPrivate)
 {
     d_ptr->q_ptr = this;
     d_ptr->m_wizardProgress = new WizardProgress(this);
@@ -301,6 +301,11 @@ Wizard::Wizard(QWidget *parent) :
     setSideWidget(new LinearProgressWidget(d_ptr->m_wizardProgress, this));
 }
 
+Wizard::~Wizard()
+{
+    delete d_ptr;
+}
+
 bool Wizard::isAutomaticProgressCreationEnabled() const
 {
     Q_D(const Wizard);
@@ -563,6 +568,7 @@ WizardProgress::~WizardProgress()
         delete it.key();
         ++it;
     }
+    delete d_ptr;
 }
 
 WizardProgressItem *WizardProgress::addItem(const QString &title)
@@ -764,7 +770,7 @@ WizardProgressItem::WizardProgressItem(WizardProgress *progress, const QString &
 
 WizardProgressItem::~WizardProgressItem()
 {
-
+    delete d_ptr;
 }
 
 void WizardProgressItem::addPage(int pageId)
diff --git a/src/libs/utils/wizard.h b/src/libs/utils/wizard.h
index 9c222408f6aa7d48d6686734f6fb99c364ff43a9..87e43278c1cfb665a018f910a1d8bd8c4c27e6fa 100644
--- a/src/libs/utils/wizard.h
+++ b/src/libs/utils/wizard.h
@@ -47,7 +47,8 @@ class QTCREATOR_UTILS_EXPORT Wizard : public QWizard
     Q_PROPERTY(bool automaticProgressCreationEnabled READ isAutomaticProgressCreationEnabled WRITE setAutomaticProgressCreationEnabled)
 
 public:
-    explicit Wizard(QWidget *parent = 0);
+    explicit Wizard(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+    virtual ~Wizard();
 
     bool isAutomaticProgressCreationEnabled() const;
     void setAutomaticProgressCreationEnabled(bool enabled);
@@ -66,7 +67,7 @@ private:
     Q_DISABLE_COPY(Wizard)
     Q_DECLARE_PRIVATE(Wizard)
 
-    QScopedPointer<WizardPrivate> d_ptr;
+    class WizardPrivate *d_ptr;
 };
 
 class WizardProgressItem;
@@ -118,7 +119,7 @@ private:
     Q_DISABLE_COPY(WizardProgress)
     Q_DECLARE_PRIVATE(WizardProgress)
 
-    QScopedPointer<WizardProgressPrivate> d_ptr;
+    class WizardProgressPrivate *d_ptr;
 };
 
 class WizardProgressItemPrivate;
@@ -150,7 +151,7 @@ private:
     Q_DISABLE_COPY(WizardProgressItem)
     Q_DECLARE_PRIVATE(WizardProgressItem)
 
-    QScopedPointer<WizardProgressItemPrivate> d_ptr;
+    class WizardProgressItemPrivate *d_ptr;
 };
 
 } // namespace Utils
diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/src/plugins/coreplugin/dialogs/settingsdialog.cpp
index 7d0f8c4656fd5c58f9c24cb01f67d8681c6a4d4c..51f12ac1e725aa2d9b7a265c3ddcadd0d908a8b7 100644
--- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp
+++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp
@@ -64,7 +64,8 @@ namespace Internal {
 
 // ----------- Category model
 
-struct Category {
+class Category {
+public:
     QString id;
     QString displayName;
     QIcon icon;
diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp
index f01dbffe72ef8ace1043eb7520f05d4f2c9e8c50..7cbe350b370501d4775bd51ea14a4f5b313367bf 100644
--- a/src/plugins/coreplugin/editortoolbar.cpp
+++ b/src/plugins/coreplugin/editortoolbar.cpp
@@ -75,7 +75,6 @@ namespace Core {
 EditorToolBar::EditorToolBar(QWidget *parent) :
         Utils::StyledBar(parent),
         m_editorList(new QComboBox(this)),
-        m_rightToolBar(new QToolBar(this)),
         m_closeButton(new QToolButton),
         m_lockButton(new QToolButton),
 
@@ -124,10 +123,6 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
     m_forwardButton= new QToolButton(this);
     m_forwardButton->setDefaultAction(m_goForwardAction);
 
-    m_rightToolBar->setLayoutDirection(Qt::RightToLeft);
-    m_rightToolBar->addWidget(m_closeButton);
-    m_rightToolBar->addWidget(m_lockButton);
-
     QHBoxLayout *toplayout = new QHBoxLayout(this);
     toplayout->setSpacing(0);
     toplayout->setMargin(0);
@@ -135,7 +130,8 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
     toplayout->addWidget(m_forwardButton);
     toplayout->addWidget(m_editorList);
     toplayout->addWidget(m_toolBarPlaceholder, 1); // Custom toolbar stretches
-    toplayout->addWidget(m_rightToolBar);
+    toplayout->addWidget(m_lockButton);
+    toplayout->addWidget(m_closeButton);
 
     setLayout(toplayout);
 
diff --git a/src/plugins/coreplugin/editortoolbar.h b/src/plugins/coreplugin/editortoolbar.h
index 227a210fe2a2589189b5ec45afdd54d80866b8e2..7713be7743c11291d6e1d754715f371245669df9 100644
--- a/src/plugins/coreplugin/editortoolbar.h
+++ b/src/plugins/coreplugin/editortoolbar.h
@@ -111,8 +111,6 @@ private:
     IEditor *currentEditor() const;
     Core::OpenEditorsModel *m_editorsListModel;
     QComboBox *m_editorList;
-    QToolBar *m_centerToolBar;
-    QToolBar *m_rightToolBar;
     QToolButton *m_closeButton;
     QToolButton *m_lockButton;
     QAction *m_goBackAction;
diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp
index b15a67b01d91422775ed737b90ddc37c2439a1ba..3e54c85cc2daa94acb6ab80cb71e9debcbf11c9c 100644
--- a/src/plugins/coreplugin/fancyactionbar.cpp
+++ b/src/plugins/coreplugin/fancyactionbar.cpp
@@ -264,31 +264,8 @@ FancyActionBar::FancyActionBar(QWidget *parent)
     spacerLayout->setSpacing(0);
     setLayout(spacerLayout);
     setContentsMargins(0,2,0,0);
-
-    m_runButton = m_debugButton = 0;
-    m_inDebugMode = false;
-
-    connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
-            this, SLOT(modeChanged(Core::IMode*)));
-
-#ifdef Q_WS_MAC
-    qApp->installEventFilter(this);
-#endif
-
 }
 
-#ifdef Q_WS_MAC
-bool FancyActionBar::eventFilter(QObject *, QEvent *e)
-{
-    if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) {
-        if (static_cast<QKeyEvent *>(e)->key() == Qt::Key_Alt)
-            updateRunDebug();
-    } else if (e->type() == QEvent::WindowDeactivate)
-        updateRunDebug();
-    return false;
-}
-#endif
-
 void FancyActionBar::addProjectSelector(QAction *action)
 {
     FancyToolButton* toolButton = new FancyToolButton(this);
@@ -300,40 +277,11 @@ void FancyActionBar::addProjectSelector(QAction *action)
 void FancyActionBar::insertAction(int index, QAction *action)
 {
     FancyToolButton *toolButton = new FancyToolButton(this);
-    if (action->objectName() == QLatin1String("ProjectExplorer.Run"))
-        m_runButton = toolButton;
-    if (action->objectName() == QLatin1String("ProjectExplorer.Debug"))
-        m_debugButton = toolButton;
-
     toolButton->setDefaultAction(action);
     connect(action, SIGNAL(changed()), toolButton, SLOT(actionChanged()));
     m_actionsLayout->insertWidget(index, toolButton);
 }
 
-void FancyActionBar::modeChanged(Core::IMode *mode)
-{
-    m_inDebugMode = (mode->id() == QLatin1String("Debugger.Mode.Debug"));
-    updateRunDebug();
-}
-
-void FancyActionBar::updateRunDebug()
-{
-    if (!m_runButton || !m_debugButton)
-        return;
-
-    bool doDebug = m_inDebugMode;
-#ifdef Q_WS_MAC
-    if (QApplication::keyboardModifiers() && Qt::AltModifier)
-        doDebug = !doDebug;
-#endif
-
-    layout()->setEnabled(false);
-    m_runButton->forceVisible(!doDebug);
-    m_debugButton->forceVisible(doDebug);
-    layout()->setEnabled(true);
-
-}
-
 QLayout *FancyActionBar::actionsLayout() const
 {
     return m_actionsLayout;
diff --git a/src/plugins/coreplugin/fancyactionbar.h b/src/plugins/coreplugin/fancyactionbar.h
index eb1d52710998921d879ffe5570b9006539074e0f..1ec1eff4449ab6a15b9ddf3d83b4d9c52d9df3b5 100644
--- a/src/plugins/coreplugin/fancyactionbar.h
+++ b/src/plugins/coreplugin/fancyactionbar.h
@@ -75,23 +75,13 @@ class FancyActionBar : public QWidget
 public:
     FancyActionBar(QWidget *parent = 0);
 
-#ifdef Q_WS_MAC
-    bool eventFilter(QObject *, QEvent *);
-#endif
     void paintEvent(QPaintEvent *event);
     void insertAction(int index, QAction *action);
     void addProjectSelector(QAction *action);
     QLayout *actionsLayout() const;
 
-private slots:
-    void modeChanged(Core::IMode *mode);
-
 private:
-    void updateRunDebug();
-    bool m_inDebugMode;
     QVBoxLayout *m_actionsLayout;
-    FancyToolButton *m_runButton;
-    FancyToolButton *m_debugButton;
 };
 
 } // namespace Internal
diff --git a/src/plugins/cpaster/codepasterprotocol.cpp b/src/plugins/cpaster/codepasterprotocol.cpp
index 2e444dcf5295ef5fae6a8c7febb3825216f16297..39b21af8e6441711510a9b0b61ce495e597f7591 100644
--- a/src/plugins/cpaster/codepasterprotocol.cpp
+++ b/src/plugins/cpaster/codepasterprotocol.cpp
@@ -48,7 +48,8 @@ enum { debug = 0 };
 
 namespace CodePaster {
 
-CodePasterProtocol::CodePasterProtocol() :
+CodePasterProtocol::CodePasterProtocol(const NetworkAccessManagerProxyPtr &nw) :
+    NetworkProtocol(nw),
     m_page(new CodePaster::CodePasterSettingsPage),
     m_pasteReply(0),
     m_fetchReply(0),
@@ -98,10 +99,7 @@ void CodePasterProtocol::fetch(const QString &id)
     link.append(hostName);
     link.append("/?format=raw&id=");
     link.append(id);
-    QUrl url(link);
-    QNetworkRequest r(url);
-
-    m_fetchReply = m_manager.get(r);
+    m_fetchReply = httpGet(link);
     connect(m_fetchReply, SIGNAL(finished()), this, SLOT(fetchFinished()));
     m_fetchId = id;
 }
@@ -116,9 +114,7 @@ void CodePasterProtocol::list()
     QString link = QLatin1String("http://");
     link += hostName;
     link += QLatin1String("/?command=browse&format=raw");
-    QUrl url(link);
-    QNetworkRequest r(url);
-    m_listReply = m_manager.get(r);
+    m_listReply = httpGet(link);
     connect(m_listReply, SIGNAL(finished()), this, SLOT(listFinished()));
 }
 
@@ -142,9 +138,7 @@ void CodePasterProtocol::paste(const QString &text,
     data += "&poster=";
     data += CGI::encodeURL(username).toLatin1();
 
-    QUrl url(QLatin1String("http://") + hostName);
-    QNetworkRequest r(url);
-    m_pasteReply = m_manager.post(r, data);
+    m_pasteReply = httpPost(QLatin1String("http://") + hostName, data);
     connect(m_pasteReply, SIGNAL(finished()), this, SLOT(pasteFinished()));
 }
 
diff --git a/src/plugins/cpaster/codepasterprotocol.h b/src/plugins/cpaster/codepasterprotocol.h
index f6e6df058a8b61aa42dc4a7697279de7afa7d035..554169fd19463733f2c4cf40fc0c2cc8b854db2a 100644
--- a/src/plugins/cpaster/codepasterprotocol.h
+++ b/src/plugins/cpaster/codepasterprotocol.h
@@ -32,8 +32,6 @@
 
 #include "protocol.h"
 
-#include <QtNetwork/QNetworkAccessManager>
-
 QT_BEGIN_NAMESPACE
 class QNetworkReply;
 QT_END_NAMESPACE
@@ -42,11 +40,11 @@ namespace CodePaster {
 
 class CodePasterSettingsPage;
 
-class CodePasterProtocol : public Protocol
+class CodePasterProtocol : public NetworkProtocol
 {
     Q_OBJECT
 public:
-    CodePasterProtocol();
+    explicit CodePasterProtocol(const NetworkAccessManagerProxyPtr &nw);
     ~CodePasterProtocol();
 
     QString name() const;
@@ -70,7 +68,6 @@ public slots:
 private:
     bool isValidHostName(const QString& hostName);
     CodePasterSettingsPage *m_page;
-    QNetworkAccessManager m_manager;
     QNetworkReply *m_pasteReply;
     QNetworkReply *m_fetchReply;
     QNetworkReply *m_listReply;
diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp
index ea2dccc5173aa02314b556d98c5d960353a52458..2dba25ce13e549d8f5ee34210d6732c655912d17 100644
--- a/src/plugins/cpaster/cpasterplugin.cpp
+++ b/src/plugins/cpaster/cpasterplugin.cpp
@@ -65,7 +65,9 @@ using namespace CodePaster;
 using namespace Core;
 using namespace TextEditor;
 
-CodepasterPlugin::CodepasterPlugin() : m_settings(new Settings)
+CodepasterPlugin::CodepasterPlugin() :
+    m_settings(new Settings),
+    m_postEditorAction(0), m_postClipboardAction(0), m_fetchAction(0)
 {
 }
 
@@ -89,9 +91,10 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *error_m
     addAutoReleasedObject(settingsPage);
 
     // Create the protocols and append them to the Settings
-    Protocol *protos[] =  { new CodePasterProtocol(),
-                            new PasteBinDotComProtocol(),
-                            new PasteBinDotCaProtocol(),
+    const QSharedPointer<NetworkAccessManagerProxy> networkAccessMgrProxy(new NetworkAccessManagerProxy);
+    Protocol *protos[] =  { new CodePasterProtocol(networkAccessMgrProxy),
+                            new PasteBinDotComProtocol(networkAccessMgrProxy),
+                            new PasteBinDotCaProtocol(networkAccessMgrProxy),
                             0};
     for(int i=0; protos[i] != 0; ++i) {
         connect(protos[i], SIGNAL(pasteDone(QString)), this, SLOT(finishPost(QString)));
@@ -116,10 +119,15 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *error_m
 
     Core::Command *command;
 
-    m_postAction = new QAction(tr("Paste Snippet..."), this);
-    command = actionManager->registerAction(m_postAction, "CodePaster.Post", globalcontext);
+    m_postEditorAction = new QAction(tr("Paste Snippet..."), this);
+    command = actionManager->registerAction(m_postEditorAction, "CodePaster.Post", globalcontext);
     command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+P")));
-    connect(m_postAction, SIGNAL(triggered()), this, SLOT(post()));
+    connect(m_postEditorAction, SIGNAL(triggered()), this, SLOT(postEditor()));
+    cpContainer->addAction(command);
+
+    m_postClipboardAction = new QAction(tr("Paste Clipboard..."), this);
+    command = actionManager->registerAction(m_postClipboardAction, "CodePaster.PostClipboard", globalcontext);
+    connect(m_postClipboardAction, SIGNAL(triggered()), this, SLOT(postClipboard()));
     cpContainer->addAction(command);
 
     m_fetchAction = new QAction(tr("Fetch Snippet..."), this);
@@ -145,6 +153,28 @@ void CodepasterPlugin::shutdown()
     }
 }
 
+void CodepasterPlugin::postEditor()
+{
+    const IEditor* editor = EditorManager::instance()->currentEditor();
+    const BaseTextEditorEditable *textEditor = qobject_cast<const BaseTextEditorEditable *>(editor);
+    if (!textEditor)
+        return;
+
+    QString data = textEditor->selectedText();
+    if (data.isEmpty())
+        data = textEditor->contents();
+    if (!data.isEmpty())
+        post(data, textEditor->editor()->mimeType());
+}
+
+void CodepasterPlugin::postClipboard()
+{
+    QString subtype = QLatin1String("plain");
+    const QString text = qApp->clipboard()->text(subtype, QClipboard::Clipboard);
+    if (!text.isEmpty())
+        post(text, QString());
+}
+
 static inline void fixSpecialCharacters(QString &data)
 {
     QChar *uc = data.data();
@@ -167,18 +197,8 @@ static inline void fixSpecialCharacters(QString &data)
     }
 }
 
-void CodepasterPlugin::post()
+void CodepasterPlugin::post(QString data, const QString &mimeType)
 {
-    const IEditor* editor = EditorManager::instance()->currentEditor();
-    const BaseTextEditorEditable *textEditor = qobject_cast<const BaseTextEditorEditable *>(editor);
-    if (!textEditor)
-        return;
-
-    QString data = textEditor->selectedText();
-    if (data.isEmpty())
-        data = textEditor->contents();
-    if (data.isEmpty())
-        return;
     fixSpecialCharacters(data);
     FileDataList lst = splitDiffToFiles(data.toLatin1());
     QString username = m_settings->username;
@@ -199,7 +219,7 @@ void CodepasterPlugin::post()
     protocolName = view.protocol();
     foreach(Protocol *protocol, m_protocols) {
         if (protocol->name() == protocolName) {
-            const Protocol::ContentType ct = Protocol::contentType(textEditor->editor()->mimeType());
+            const Protocol::ContentType ct = Protocol::contentType(mimeType);
             protocol->paste(data, ct, username, comment, description);
             break;
         }
diff --git a/src/plugins/cpaster/cpasterplugin.h b/src/plugins/cpaster/cpasterplugin.h
index c07695c28aac44e255bee6e1936970c4bdccf7b7..6278cd1473ed9720dcaadb3c140876dfd447d4e5 100644
--- a/src/plugins/cpaster/cpasterplugin.h
+++ b/src/plugins/cpaster/cpasterplugin.h
@@ -58,7 +58,8 @@ public:
     virtual void shutdown();
 
 public slots:
-    void post();
+    void postEditor();
+    void postClipboard();
     void fetch();
     void finishPost(const QString &link);
     void finishFetch(const QString &titleDescription,
@@ -66,8 +67,11 @@ public slots:
                      bool error);
 
 private:
+    void post(QString data, const QString &mimeType);
+
     const QSharedPointer<Settings> m_settings;
-    QAction *m_postAction;
+    QAction *m_postEditorAction;
+    QAction *m_postClipboardAction;
     QAction *m_fetchAction;
     QList<Protocol*> m_protocols;
     QStringList m_fetchedSnippets;
diff --git a/src/plugins/cpaster/pastebindotcaprotocol.cpp b/src/plugins/cpaster/pastebindotcaprotocol.cpp
index c40276cd169c906475936927ba1134712746acb7..7984ee64c8a4afc8fcb3b43470d6d6bc0d8a0fa3 100644
--- a/src/plugins/cpaster/pastebindotcaprotocol.cpp
+++ b/src/plugins/cpaster/pastebindotcaprotocol.cpp
@@ -32,11 +32,13 @@
 
 #include <QtNetwork/QNetworkReply>
 
-using namespace Core;
 namespace CodePaster {
-PasteBinDotCaProtocol::PasteBinDotCaProtocol()
+PasteBinDotCaProtocol::PasteBinDotCaProtocol(const NetworkAccessManagerProxyPtr &nw) :
+    NetworkProtocol(nw),
+    m_fetchReply(0),
+    m_postId(-1)
 {
-    connect(&http, SIGNAL(requestFinished(int,bool)),
+    connect(&m_http, SIGNAL(requestFinished(int,bool)),
             this, SLOT(postRequestFinished(int,bool)));
 }
 
@@ -44,12 +46,9 @@ void PasteBinDotCaProtocol::fetch(const QString &id)
 {
     QString link = QLatin1String("http://pastebin.ca/raw/");
     link.append(id);
-    QUrl url(link);
-    QNetworkRequest r(url);
-
-    reply = manager.get(r);
-    connect(reply, SIGNAL(finished()), this, SLOT(fetchFinished()));
-    fetchId = id;
+    m_fetchReply = httpGet(link);
+    connect(m_fetchReply, SIGNAL(finished()), this, SLOT(fetchFinished()));
+    m_fetchId = id;
 }
 
 void PasteBinDotCaProtocol::paste(const QString &text,
@@ -69,20 +68,20 @@ void PasteBinDotCaProtocol::paste(const QString &text,
     QHttpRequestHeader header("POST", "/quiet-paste.php");
     header.setValue("host", "pastebin.ca" );
     header.setContentType("application/x-www-form-urlencoded");
-    http.setHost("pastebin.ca", QHttp::ConnectionModeHttp);
+    m_http.setHost("pastebin.ca", QHttp::ConnectionModeHttp);
     header.setValue("User-Agent", "CreatorPastebin");
-    postId = http.request(header, data.toAscii());
+    m_postId = m_http.request(header, data.toAscii());
 }
 
 void PasteBinDotCaProtocol::postRequestFinished(int id, bool error)
 {
     QString link;
-    if (id == postId) {
+    if (id == m_postId) {
         if (!error) {
-            QByteArray data = http.readAll();
+            QByteArray data = m_http.readAll();
             link = QString::fromLatin1("http://pastebin.ca/") + QString(data).remove("SUCCESS:");
         } else
-            link = http.errorString();
+            link = m_http.errorString();
         emit pasteDone(link);
     }
 }
@@ -91,15 +90,15 @@ void PasteBinDotCaProtocol::fetchFinished()
 {
     QString title;
     QString content;
-    bool error = reply->error();
+    bool error = m_fetchReply->error();
     if (error) {
-        content = reply->errorString();
+        content = m_fetchReply->errorString();
     } else {
-        title = QString::fromLatin1("Pastebin.ca: %1").arg(fetchId);
-        content = reply->readAll();
+        title = QString::fromLatin1("Pastebin.ca: %1").arg(m_fetchId);
+        content = m_fetchReply->readAll();
     }
-    reply->deleteLater();
-    reply = 0;
+    m_fetchReply->deleteLater();
+    m_fetchReply = 0;
     emit fetchDone(title, content, error);
 }
 } // namespace CodePaster
diff --git a/src/plugins/cpaster/pastebindotcaprotocol.h b/src/plugins/cpaster/pastebindotcaprotocol.h
index b1d0c07bd0cf542d803b4845d2462b93c4d765cc..4cc766d4b016f665011523ce7fe7c3ebc80638d9 100644
--- a/src/plugins/cpaster/pastebindotcaprotocol.h
+++ b/src/plugins/cpaster/pastebindotcaprotocol.h
@@ -32,15 +32,14 @@
 
 #include "protocol.h"
 
-#include <QtNetwork/QNetworkAccessManager>
 #include <QtNetwork/QHttp>
 
 namespace CodePaster {
-class PasteBinDotCaProtocol : public Protocol
+class PasteBinDotCaProtocol : public NetworkProtocol
 {
     Q_OBJECT
 public:
-    PasteBinDotCaProtocol();
+    explicit PasteBinDotCaProtocol(const NetworkAccessManagerProxyPtr &nw);
     QString name() const { return QLatin1String("Pastebin.Ca"); }
 
     bool hasSettings() const { return false; }
@@ -58,12 +57,11 @@ public slots:
     void postRequestFinished(int id, bool error);
 
 private:
-    QNetworkAccessManager manager;
-    QNetworkReply *reply;
-    QString fetchId;
+    QNetworkReply *m_fetchReply;
+    QString m_fetchId;
 
-    QHttp http;
-    int postId;
+    QHttp m_http;
+    int m_postId;
 };
 
 } // namespace CodePaster
diff --git a/src/plugins/cpaster/pastebindotcomprotocol.cpp b/src/plugins/cpaster/pastebindotcomprotocol.cpp
index 5e6f8498cb8be1d7eed43b451f14c95cbb9528c9..eb8d631f3f56def9c27492c09d55cf1fd76f49da 100644
--- a/src/plugins/cpaster/pastebindotcomprotocol.cpp
+++ b/src/plugins/cpaster/pastebindotcomprotocol.cpp
@@ -38,6 +38,7 @@
 #include <QtCore/QTextStream>
 #include <QtCore/QXmlStreamReader>
 #include <QtCore/QXmlStreamAttributes>
+#include <QtCore/QByteArray>
 
 #include <QtNetwork/QNetworkReply>
 
@@ -47,7 +48,8 @@ static const char pastePhpScriptpC[] = "api_public.php";
 static const char fetchPhpScriptpC[] = "raw.php";
 
 namespace CodePaster {
-PasteBinDotComProtocol::PasteBinDotComProtocol() :
+PasteBinDotComProtocol::PasteBinDotComProtocol(const NetworkAccessManagerProxyPtr &nw) :
+    NetworkProtocol(nw),
     m_settings(new PasteBinDotComSettings),
     m_fetchReply(0),
     m_pasteReply(0),
@@ -105,31 +107,29 @@ void PasteBinDotComProtocol::paste(const QString &text,
     QTC_ASSERT(!m_pasteReply, return;)
 
     // Format body
-    m_pasteData = format(ct);
-    if (!m_pasteData.isEmpty())
-        m_pasteData.append('&');
-    m_pasteData += "paste_name=";
-    m_pasteData += QUrl::toPercentEncoding(username);
+    QByteArray pasteData = format(ct);
+    if (!pasteData.isEmpty())
+        pasteData.append('&');
+    pasteData += "paste_name=";
+    pasteData += QUrl::toPercentEncoding(username);
 
     const QString subDomain = m_settings->hostPrefix();
     if (!subDomain.isEmpty()) {
-        m_pasteData += "&paste_subdomain=";
-        m_pasteData += QUrl::toPercentEncoding(subDomain);
+        pasteData += "&paste_subdomain=";
+        pasteData += QUrl::toPercentEncoding(subDomain);
     }
 
-    m_pasteData += "&paste_code=";
-    m_pasteData += QUrl::toPercentEncoding(fixNewLines(text));
+    pasteData += "&paste_code=";
+    pasteData += QUrl::toPercentEncoding(fixNewLines(text));
 
     // fire request
     QString link;
     QTextStream(&link) << "http://" << hostName(false) << '/' << pastePhpScriptpC;
 
-    QUrl url(link);
-    QNetworkRequest r(url);
-    m_pasteReply = m_manager.post(r, m_pasteData);
+    m_pasteReply = httpPost(link, pasteData);
     connect(m_pasteReply, SIGNAL(finished()), this, SLOT(pasteFinished()));
     if (debug)
-        qDebug() << "paste: sending " << m_pasteReply << link << m_pasteData;
+        qDebug() << "paste: sending " << m_pasteReply << link << pasteData;
 }
 
 void PasteBinDotComProtocol::pasteFinished()
@@ -164,10 +164,8 @@ void PasteBinDotComProtocol::fetch(const QString &id)
 
     if (debug)
         qDebug() << "fetch: sending " << link;
-    QUrl url(link);
-    QNetworkRequest r(url);
 
-    m_fetchReply = m_manager.get(r);
+    m_fetchReply = httpGet(link);
     connect(m_fetchReply, SIGNAL(finished()), this, SLOT(fetchFinished()));
     m_fetchId = id;
 }
@@ -212,9 +210,7 @@ void PasteBinDotComProtocol::list()
     QTC_ASSERT(!m_listReply, return;)
 
     // fire request
-    QUrl url(QLatin1String("http://") + hostName(true));
-    QNetworkRequest r(url);
-    m_listReply = m_manager.get(r);
+    m_listReply = httpGet(QLatin1String("http://") + hostName(true));
     connect(m_listReply, SIGNAL(finished()), this, SLOT(listFinished()));
     if (debug)
         qDebug() << "list: sending " << m_listReply;
diff --git a/src/plugins/cpaster/pastebindotcomprotocol.h b/src/plugins/cpaster/pastebindotcomprotocol.h
index a7e2d30513726546294c22aac0fbf487527fd0f3..612fff7ac02f2dc6f0676f427850c510f3204dcc 100644
--- a/src/plugins/cpaster/pastebindotcomprotocol.h
+++ b/src/plugins/cpaster/pastebindotcomprotocol.h
@@ -32,19 +32,14 @@
 
 #include "protocol.h"
 
-#include <QtNetwork/QNetworkAccessManager>
-#include <QtNetwork/QHttp>
-
-#include <QtCore/QByteArray>
-
 namespace CodePaster {
 class PasteBinDotComSettings;
 
-class PasteBinDotComProtocol : public Protocol
+class PasteBinDotComProtocol : public NetworkProtocol
 {
     Q_OBJECT
 public:
-    PasteBinDotComProtocol();
+    explicit PasteBinDotComProtocol(const NetworkAccessManagerProxyPtr &nw);
 
     QString name() const { return QLatin1String("Pastebin.Com"); }
 
@@ -69,11 +64,9 @@ private:
     QString hostName(bool withSubDomain) const;
 
     PasteBinDotComSettings *m_settings;
-    QNetworkAccessManager m_manager;
     QNetworkReply *m_fetchReply;
     QNetworkReply *m_pasteReply;
     QNetworkReply *m_listReply;
-    QByteArray m_pasteData;
 
     QString m_fetchId;
     int m_postId;
diff --git a/src/plugins/cpaster/protocol.cpp b/src/plugins/cpaster/protocol.cpp
index be649f06775cded8a9655a1917ed7178ce477995..0f6e58a7e911ea0de2ef5a919194e0dc50a35641 100644
--- a/src/plugins/cpaster/protocol.cpp
+++ b/src/plugins/cpaster/protocol.cpp
@@ -31,6 +31,11 @@
 #include <cpptools/cpptoolsconstants.h>
 #include <qmljseditor/qmljseditorconstants.h>
 
+#include <QtNetwork/QNetworkAccessManager>
+#include <QtNetwork/QNetworkRequest>
+
+#include <QtCore/QUrl>
+
 namespace CodePaster {
 
 Protocol::Protocol()
@@ -108,4 +113,46 @@ QString Protocol::textFromHtml(QString data)
     data.replace(QLatin1String("&amp;"), QString(QLatin1Char('&')));
     return data;
 }
+
+// ------------ NetworkAccessManagerProxy
+NetworkAccessManagerProxy::NetworkAccessManagerProxy()
+{
+}
+
+NetworkAccessManagerProxy::~NetworkAccessManagerProxy()
+{
+}
+
+QNetworkReply *NetworkAccessManagerProxy::httpGet(const QString &link)
+{
+    QUrl url(link);
+    QNetworkRequest r(url);
+    return networkAccessManager()->get(r);
+}
+
+QNetworkReply *NetworkAccessManagerProxy::httpPost(const QString &link, const QByteArray &data)
+{
+    QUrl url(link);
+    QNetworkRequest r(url);
+    return networkAccessManager()->post(r, data);
+}
+
+QNetworkAccessManager *NetworkAccessManagerProxy::networkAccessManager()
+{
+    if (m_networkAccessManager.isNull())
+        m_networkAccessManager.reset(new QNetworkAccessManager);
+    return m_networkAccessManager.data();
+}
+
+// --------- NetworkProtocol
+
+NetworkProtocol::NetworkProtocol(const NetworkAccessManagerProxyPtr &nw) :
+    m_networkAccessManager(nw)
+{
+}
+
+NetworkProtocol::~NetworkProtocol()
+{
+}
+
 } //namespace CodePaster
diff --git a/src/plugins/cpaster/protocol.h b/src/plugins/cpaster/protocol.h
index 914a5748a4e58639c23d84bea87e4ff6ddd3d227..6ee95f9fdd61204b00b42e0df73b38b8d12e8289 100644
--- a/src/plugins/cpaster/protocol.h
+++ b/src/plugins/cpaster/protocol.h
@@ -31,6 +31,13 @@
 #define PROTOCOL_H
 
 #include <QtCore/QObject>
+#include <QtCore/QScopedPointer>
+#include <QtCore/QSharedPointer>
+
+QT_BEGIN_NAMESPACE
+class QNetworkAccessManager;
+class QNetworkReply;
+QT_END_NAMESPACE
 
 namespace Core {
     class IOptionsPage;
@@ -50,7 +57,7 @@ public:
         PostCommentCapability = 0x2,
         PostDescriptionCapability = 0x4
     };
-    Protocol();
+
     virtual ~Protocol();
 
     virtual QString name() const = 0;
@@ -82,9 +89,54 @@ signals:
     void listDone(const QString &name, const QStringList &result);
 
 protected:
+    Protocol();
     static QString textFromHtml(QString data);
     static QString fixNewLines(QString in);
+};
+
+/* Proxy for NetworkAccessManager that can be shared with
+ * delayed initialization and conveniences
+ * for HTTP-requests. */
+
+class NetworkAccessManagerProxy {
+    Q_DISABLE_COPY(NetworkAccessManagerProxy)
+public:
+    NetworkAccessManagerProxy();
+    ~NetworkAccessManagerProxy();
+
+    QNetworkReply *httpGet(const QString &url);
+    QNetworkReply *httpPost(const QString &link, const QByteArray &data);
+    QNetworkAccessManager *networkAccessManager();
+
+private:
+    QScopedPointer<QNetworkAccessManager> m_networkAccessManager;
+};
+
+/* Network-based protocol: Provides access with delayed
+ * initialization to a QNetworkAccessManager and conveniences
+ * for HTTP-requests. */
+
+class NetworkProtocol : public Protocol {
+    Q_OBJECT
+public:
+    virtual ~NetworkProtocol();
+
+protected:
+    typedef QSharedPointer<NetworkAccessManagerProxy> NetworkAccessManagerProxyPtr;
+
+    explicit NetworkProtocol(const NetworkAccessManagerProxyPtr &nw);
+
+    inline QNetworkReply *httpGet(const QString &url)
+    { return m_networkAccessManager->httpGet(url); }
+
+    inline QNetworkReply *httpPost(const QString &link, const QByteArray &data)
+    { return m_networkAccessManager->httpPost(link, data); }
+
+    inline QNetworkAccessManager *networkAccessManager()
+    { return m_networkAccessManager->networkAccessManager(); }
 
+private:
+    const NetworkAccessManagerProxyPtr m_networkAccessManager;
 };
 
 } //namespace CodePaster
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 502c96e3eda772e2b35b1e8399c4d79dcbdc922a..965b8385a5a14188c08a279e19609873728fc972 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -615,8 +615,11 @@ void GdbEngine::handleResponse(const QByteArray &buff)
 void GdbEngine::readGdbStandardError()
 {
     QByteArray err = m_gdbProc.readAllStandardError();
+    debugMessage(_("UNEXPECTED GDB STDERR: " + err));
     if (err == "Undefined command: \"bb\".  Try \"help\".\n")
         return;
+    if (err.startsWith("BFD: reopening"))
+        return;
     qWarning() << "Unexpected gdb stderr:" << err;
 }
 
@@ -1651,11 +1654,20 @@ void GdbEngine::handleInferiorShutdown(const GdbResponse &response)
         debugMessage(_("INFERIOR SUCCESSFULLY SHUT DOWN"));
         setState(InferiorShutDown);
     } else {
-        debugMessage(_("INFERIOR SHUTDOWN FAILED"));
-        setState(InferiorShutdownFailed);
-        QString msg = m_gdbAdapter->msgInferiorStopFailed(
-            QString::fromLocal8Bit(response.data.findChild("msg").data()));
-        showMessageBox(QMessageBox::Critical, tr("Failed to shut down application"), msg);
+        QByteArray ba = response.data.findChild("msg").data();
+        if (ba.contains(": No such file or directory.")) {
+            // This happens when someone removed the binary behind our back.
+            // It is not really an error from a user's point of view.
+            debugMessage(_("INFERIOR SUCCESSFULLY SHUT DOWN"));
+            debugMessage(_("NOTE: " + ba));
+            setState(InferiorShutDown);
+        } else {
+            debugMessage(_("INFERIOR SHUTDOWN FAILED"));
+            setState(InferiorShutdownFailed);
+            showMessageBox(QMessageBox::Critical,
+                tr("Failed to shut down application"),
+                m_gdbAdapter->msgInferiorStopFailed(QString::fromLocal8Bit(ba)));
+        }
     }
     shutdown(); // re-iterate...
 }
diff --git a/src/plugins/projectexplorer/outputparser_test.cpp b/src/plugins/projectexplorer/outputparser_test.cpp
index 09dc063979e8b37dd5e63b5562b98a9e1f504770..28a83b50011a1e5a246bfa1e15e2dc3e43b663dc 100644
--- a/src/plugins/projectexplorer/outputparser_test.cpp
+++ b/src/plugins/projectexplorer/outputparser_test.cpp
@@ -29,6 +29,8 @@
 
 #include "outputparser_test.h"
 
+#if defined(WITH_TESTS)
+
 #include <QtTest>
 
 using namespace ProjectExplorer;
@@ -132,7 +134,6 @@ void OutputParserTester::stdError(const QString &line)
 void OutputParserTester::appendOutputParser(IOutputParser *parser)
 {
     Q_ASSERT(!childParser());
-    Q_ASSERT(!parser->childParser());
 
     IOutputParser::appendOutputParser(parser);
     parser->appendOutputParser(this);
@@ -157,3 +158,5 @@ void OutputParserTester::reset()
     m_receivedTasks.clear();
     m_receivedOutput = QString();
 }
+
+#endif
diff --git a/src/plugins/projectexplorer/outputparser_test.h b/src/plugins/projectexplorer/outputparser_test.h
index 89b2292c3836cda348a8891dd703527580e9a12e..8241766bb5bb6602fcdeeb17548401558ad35d2f 100644
--- a/src/plugins/projectexplorer/outputparser_test.h
+++ b/src/plugins/projectexplorer/outputparser_test.h
@@ -30,7 +30,10 @@
 #ifndef OUTPUTPARSER_TESTER_H
 #define OUTPUTPARSER_TESTER_H
 
+#if defined(WITH_TESTS)
+
 #include "projectexplorer_export.h"
+#include "metatypedeclarations.h"
 #include "ioutputparser.h"
 
 namespace ProjectExplorer {
@@ -86,4 +89,6 @@ private:
 
 Q_DECLARE_METATYPE(ProjectExplorer::OutputParserTester::Channel)
 
+#endif
+
 #endif // OUTPUTPARSER_TESTER_H
diff --git a/src/plugins/projectexplorer/targetsettingspanel.cpp b/src/plugins/projectexplorer/targetsettingspanel.cpp
index be6d51122c36c92714d2e899012ac470460359aa..c21ccf072c6ac3d6de16c34ff3c8461fc1ec0b37 100644
--- a/src/plugins/projectexplorer/targetsettingspanel.cpp
+++ b/src/plugins/projectexplorer/targetsettingspanel.cpp
@@ -114,6 +114,9 @@ void TargetSettingsPanelWidget::setupUi()
     connect(m_selector, SIGNAL(currentChanged(int,int)),
             this, SLOT(currentTargetChanged(int,int)));
 
+    // Save active target now as it will change when targets are added:
+    Target *activeTarget = m_project->activeTarget();
+
     foreach (Target *t, m_project->targets())
         targetAdded(t);
 
@@ -122,11 +125,10 @@ void TargetSettingsPanelWidget::setupUi()
     connect(m_selector, SIGNAL(removeButtonClicked()),
             this, SLOT(removeTarget()));
 
-    if (m_project->activeTarget()) {
-        m_selector->setCurrentIndex(m_targets.indexOf(m_project->activeTarget()));
-    }
-
     updateTargetAddAndRemoveButtons();
+
+    // Restore target originally set:
+    m_project->setActiveTarget(activeTarget);
 }
 
 void TargetSettingsPanelWidget::currentTargetChanged(int targetIndex, int subIndex)
@@ -136,6 +138,16 @@ void TargetSettingsPanelWidget::currentTargetChanged(int targetIndex, int subInd
     if (subIndex < -1 || subIndex >= 2)
         return;
 
+    if (targetIndex == -1 || subIndex == -1) { // no more targets!
+        delete m_panelWidgets[0];
+        m_panelWidgets[0] = 0;
+        delete m_panelWidgets[1];
+        m_panelWidgets[1] = 0;
+
+        m_centralWidget->setCurrentWidget(m_noTargetLabel);
+        return;
+    }
+
     Target *target = m_targets.at(targetIndex);
 
     // Target was not actually changed:
@@ -147,13 +159,8 @@ void TargetSettingsPanelWidget::currentTargetChanged(int targetIndex, int subInd
         return;
     }
 
-    m_currentTarget = target;
-
     // Target has changed:
-    if (targetIndex == -1) { // no more targets!
-        m_centralWidget->setCurrentWidget(m_noTargetLabel);
-        return;
-    }
+    m_currentTarget = target;
 
     PanelsWidget *buildPanel = new PanelsWidget(m_centralWidget);
     PanelsWidget *runPanel = new PanelsWidget(m_centralWidget);
diff --git a/src/plugins/qmldesigner/core/model/propertyparser.cpp b/src/plugins/qmldesigner/core/model/propertyparser.cpp
index ded2b374cc5e804a472abbbcfaf3d91201ff7a48..4043e81827ae93f98fdf4497fe4c0affb0e8c374 100644
--- a/src/plugins/qmldesigner/core/model/propertyparser.cpp
+++ b/src/plugins/qmldesigner/core/model/propertyparser.cpp
@@ -63,10 +63,13 @@ QVariant read(const QString &typeStr, const QString &str, const MetaInfo &metaIn
 QVariant read(const QString &typeStr, const QString &str)
 {
     int type = QMetaType::type(typeStr.toAscii().constData());
-    if (type == 0)
+    if (type == 0) {
         qWarning() << "Type " << typeStr
                 << " is unknown to QMetaType system. Cannot create properly typed QVariant for value "
                 << str;
+        // Fall back to a QVariant of type String
+        return QVariant(str);
+    }
     return read(type, str);
 }
 
@@ -108,9 +111,9 @@ QVariant read(int variantType, const QString &str)
     }
 
     if (!conversionOk) {
-        value = QVariant();
         qWarning() << "Could not convert" << str
                    << "to" << QMetaType::typeName(variantType);
+        value = QVariant(str);
     }
 
     return value;
diff --git a/src/plugins/qmldesigner/core/model/rewriterview.cpp b/src/plugins/qmldesigner/core/model/rewriterview.cpp
index fc4f608af588df6cdeec3f6d04dc10eea5bca958..94c1244daf16c84b7d9b7ad39d4120aa6d4e2dcc 100644
--- a/src/plugins/qmldesigner/core/model/rewriterview.cpp
+++ b/src/plugins/qmldesigner/core/model/rewriterview.cpp
@@ -538,7 +538,7 @@ void RewriterView::qmlTextChanged()
             default: {
                 emitCustomNotification(StartRewriterAmend);
                 ModelAmender differenceHandler(m_textToModelMerger.data());
-                if (m_textToModelMerger->load(newQmlText.toUtf8(), differenceHandler)) {
+                if (m_textToModelMerger->load(newQmlText, differenceHandler)) {
                     lastCorrectQmlSource = newQmlText;
                 }
                 emitCustomNotification(EndRewriterAmend);
diff --git a/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp
index dd264fbfd75f4aee006a840c7de0987eedb4e413..2d214e82512004e6cab138d321fe6ab32de38147 100644
--- a/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp
+++ b/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp
@@ -255,8 +255,10 @@ void TextToModelMerger::setupImports(const Document::Ptr &doc,
         differenceHandler.importAbsentInQMl(import);
 }
 
-bool TextToModelMerger::load(const QByteArray &data, DifferenceHandler &differenceHandler)
+bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceHandler)
 {
+//    qDebug() << "TextToModelMerger::load with data:" << data;
+
     const QUrl url = m_rewriterView->model()->fileUrl();
     const QStringList importPaths = m_rewriterView->textModifier()->importPaths();
     setActive(true);
@@ -266,7 +268,7 @@ bool TextToModelMerger::load(const QByteArray &data, DifferenceHandler &differen
         foreach (const QString &importPath, importPaths)
             engine.addImportPath(importPath);
         QDeclarativeComponent comp(&engine);
-        comp.setData(data, url);
+        comp.setData(data.toUtf8(), url);
         if (comp.status() == QDeclarativeComponent::Error) {
             QList<RewriterView::Error> errors;
             foreach (const QDeclarativeError &error, comp.errors())
@@ -288,7 +290,7 @@ bool TextToModelMerger::load(const QByteArray &data, DifferenceHandler &differen
         Snapshot snapshot = m_rewriterView->textModifier()->getSnapshot();
         const QString fileName = url.toLocalFile();
         Document::Ptr doc = Document::create(fileName.isEmpty() ? QLatin1String("<internal>") : fileName);
-        doc->setSource(QString::fromUtf8(data.constData()));
+        doc->setSource(data);
         doc->parseQml();
         snapshot.insert(doc);
         ReadingContext ctxt(snapshot, doc, importPaths);
@@ -671,7 +673,14 @@ QVariant TextToModelMerger::convertToVariant(const ModelNode &node,
         const PropertyMetaInfo propertyMetaInfo = nodeMetaInfo.property(astName, true);
 
         if (propertyMetaInfo.isValid()) {
-            return Internal::PropertyParser::read(propertyMetaInfo.variantTypeId(), cleanedValue);
+            QVariant::Type type = propertyMetaInfo.variantTypeId();
+            if (type == QVariant::Invalid) {
+                const QString propType = propertyMetaInfo.type();
+//                qDebug() << "converting" << cleanedValue << "to" << propType;
+                return Internal::PropertyParser::read(propType, cleanedValue, node.metaInfo().metaInfo());
+            } else {
+                return Internal::PropertyParser::read(type, cleanedValue);
+            }
         } else if (node.type() == QLatin1String("Qt/PropertyChanges")) {
             // In the future, we should do the type resolving in a second pass, or delay setting properties until the full file has been parsed.
             return QVariant(cleanedValue);
@@ -827,6 +836,10 @@ void ModelAmender::shouldBeNodeListProperty(AbstractProperty &modelProperty,
 
 void ModelAmender::variantValuesDiffer(VariantProperty &modelProperty, const QVariant &qmlVariantValue, const QString &dynamicType)
 {
+//    qDebug()<< "ModelAmender::variantValuesDiffer for property"<<modelProperty.name()
+//            << "in node" << modelProperty.parentModelNode().id()
+//            << ", old value:" << modelProperty.value()
+//            << "new value:" << qmlVariantValue;
     if (dynamicType.isEmpty())
         modelProperty.setValue(qmlVariantValue);
     else
diff --git a/src/plugins/qmldesigner/core/model/texttomodelmerger.h b/src/plugins/qmldesigner/core/model/texttomodelmerger.h
index 19a6e4738db4a59feb775f18a41badccfcee80c8..f57dead67fbdaa7f833d4793ec97793de513b87a 100644
--- a/src/plugins/qmldesigner/core/model/texttomodelmerger.h
+++ b/src/plugins/qmldesigner/core/model/texttomodelmerger.h
@@ -55,7 +55,7 @@ public:
     bool isActive() const;
 
     void setupImports(const QmlJS::Document::Ptr &doc, DifferenceHandler &differenceHandler);
-    bool load(const QByteArray &data, DifferenceHandler &differenceHandler);
+    bool load(const QString &data, DifferenceHandler &differenceHandler);
 
     RewriterView *view() const
     { return m_rewriterView; }
diff --git a/src/plugins/qmlprojectmanager/fileformat/filesystemwatcher.h b/src/plugins/qmlprojectmanager/fileformat/filesystemwatcher.h
index cc08a85b550c75e1a9e501223018ba0eb99db7be..7f9549c50ac131ef0c63e40a4ed5ff1c64ec5094 100644
--- a/src/plugins/qmlprojectmanager/fileformat/filesystemwatcher.h
+++ b/src/plugins/qmlprojectmanager/fileformat/filesystemwatcher.h
@@ -36,8 +36,10 @@
 #include <QtCore/QStringList>
 #include <QtCore/QMap>
 
+QT_BEGIN_NAMESPACE
 class QTimer;
 class QFileSystemWatcher;
+QT_END_NAMESPACE
 
 namespace QmlProjectManager {
 
diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizarddialog.cpp b/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizarddialog.cpp
index d478bc507520de836ee15c368e91102bc64d6d4f..1870531b7b699fe0ab4a6136aa545b8432fce5a7 100644
--- a/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizarddialog.cpp
+++ b/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizarddialog.cpp
@@ -52,7 +52,7 @@ CustomWidgetWizardDialog::CustomWidgetWizardDialog(const QString &templateName,
     setIntroDescription(tr("This wizard generates a Qt4 Designer Custom Widget "
                            "or a Qt4 Designer Custom Widget Collection project."));
 
-    addTargetsPage(BaseQt4ProjectWizardDialog::desktopTarget());
+    addTargetSetupPage(BaseQt4ProjectWizardDialog::desktopTarget());
     m_widgetPageId = addPage(m_widgetsPage);
     m_pluginPageId = addPage(m_pluginPage);
 
diff --git a/src/plugins/qt4projectmanager/qt-s60/abldparser.cpp b/src/plugins/qt4projectmanager/qt-s60/abldparser.cpp
index 9cc7595f3ef6d4a5129ab68ebbe4391cf9160454..692d7b30e838ffa5a0c3dd903135a591d8bf33af 100644
--- a/src/plugins/qt4projectmanager/qt-s60/abldparser.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/abldparser.cpp
@@ -174,3 +174,53 @@ void AbldParser::stdError(const QString &line)
     }
     IOutputParser::stdError(line);
 }
+
+// Unit tests:
+
+#ifdef WITH_TESTS
+#   include <QTest>
+
+#   include "qt4projectmanagerplugin.h"
+
+#   include "projectexplorer/outputparser_test.h"
+
+using namespace Qt4ProjectManager::Internal;
+
+void Qt4ProjectManagerPlugin::testAbldOutputParsers_data()
+{
+    QTest::addColumn<QString>("input");
+    QTest::addColumn<OutputParserTester::Channel>("inputChannel");
+    QTest::addColumn<QString>("childStdOutLines");
+    QTest::addColumn<QString>("childStdErrLines");
+    QTest::addColumn<QList<ProjectExplorer::Task> >("tasks");
+    QTest::addColumn<QString>("outputLines");
+
+
+    QTest::newRow("pass-through stdout")
+            << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT
+            << QString::fromLatin1("Sometext") << QString()
+            << QList<ProjectExplorer::Task>()
+            << QString();
+    QTest::newRow("pass-through stderr")
+            << QString::fromLatin1("Sometext") << OutputParserTester::STDERR
+            << QString() << QString::fromLatin1("Sometext")
+            << QList<ProjectExplorer::Task>()
+            << QString();
+}
+
+void Qt4ProjectManagerPlugin::testAbldOutputParsers()
+{
+    OutputParserTester testbench;
+    testbench.appendOutputParser(new AbldParser);
+    QFETCH(QString, input);
+    QFETCH(OutputParserTester::Channel, inputChannel);
+    QFETCH(QList<Task>, tasks);
+    QFETCH(QString, childStdOutLines);
+    QFETCH(QString, childStdErrLines);
+    QFETCH(QString, outputLines);
+
+    testbench.testParsing(input, inputChannel,
+                          tasks, childStdOutLines, childStdErrLines,
+                          outputLines);
+}
+#endif
diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.pro b/src/plugins/qt4projectmanager/qt4projectmanager.pro
index eb3b98f98933c776b9765c4154a5da9e029d9299..b78f585a99859254cfad816aaacd8b8cb76cb8d7 100644
--- a/src/plugins/qt4projectmanager/qt4projectmanager.pro
+++ b/src/plugins/qt4projectmanager/qt4projectmanager.pro
@@ -27,7 +27,6 @@ HEADERS += qt4projectmanagerplugin.h \
     wizards/modulespage.h \
     wizards/filespage.h \
     wizards/qtwizard.h \
-    wizards/targetspage.h \
     wizards/targetsetuppage.h \
     qt4projectmanagerconstants.h \
     makestep.h \
@@ -69,7 +68,6 @@ SOURCES += qt4projectmanagerplugin.cpp \
     wizards/modulespage.cpp \
     wizards/filespage.cpp \
     wizards/qtwizard.cpp \
-    wizards/targetspage.cpp \
     wizards/targetsetuppage.cpp \
     makestep.cpp \
     qmakestep.cpp \
diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp
index 096356267cdfc0fe35dc50ef75380bc2f0e9a8d8..674fb048559fd7fd1fdd0d98fd272e0f609428a0 100644
--- a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp
+++ b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp
@@ -266,11 +266,6 @@ void Qt4ProjectManagerPlugin::testBasicProjectLoading()
     QVERIFY(qt4project->rootProjectNode()->projectType() == ApplicationTemplate);
     QVERIFY(m_projectExplorer->currentProject() != 0);
 }
-
-void Qt4ProjectManagerPlugin::testNotYetImplemented()
-{
-    QCOMPARE(1+1, 2);
-}
 #endif
 
 Q_EXPORT_PLUGIN(Qt4ProjectManagerPlugin)
diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h
index 1fc0c9f43a5db5ad561fff7330e22c495a695960..b8af4ccf8602a1c92075029b4aa8def2b047632b 100644
--- a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h
+++ b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h
@@ -76,7 +76,9 @@ private slots:
 
 #ifdef WITH_TESTS
     void testBasicProjectLoading();
-    void testNotYetImplemented();
+
+    void testAbldOutputParsers_data();
+    void testAbldOutputParsers();
 #endif
 
 private:
diff --git a/src/plugins/qt4projectmanager/wizards/consoleappwizarddialog.cpp b/src/plugins/qt4projectmanager/wizards/consoleappwizarddialog.cpp
index d34793489e45235f01d11538451ae0eb580cb298..fc59468d94b8a6aaccbf257fe94f10bca5a8cdec 100644
--- a/src/plugins/qt4projectmanager/wizards/consoleappwizarddialog.cpp
+++ b/src/plugins/qt4projectmanager/wizards/consoleappwizarddialog.cpp
@@ -52,7 +52,7 @@ ConsoleAppWizardDialog::ConsoleAppWizardDialog(const QString &templateName,
                           "provide a GUI."));
 
     addModulesPage();
-    addTargetsPage();
+    addTargetSetupPage();
 
     foreach (QWizardPage *p, extensionPages)
         addPage(p);
diff --git a/src/plugins/qt4projectmanager/wizards/emptyprojectwizarddialog.cpp b/src/plugins/qt4projectmanager/wizards/emptyprojectwizarddialog.cpp
index a10dd6048730fe8c056f3f575a7296648b7affe6..e572120cf3defb6544744f7c0ad09eb8a0fd5b6e 100644
--- a/src/plugins/qt4projectmanager/wizards/emptyprojectwizarddialog.cpp
+++ b/src/plugins/qt4projectmanager/wizards/emptyprojectwizarddialog.cpp
@@ -45,7 +45,7 @@ EmptyProjectWizardDialog::EmptyProjectWizardDialog(const QString &templateName,
     setIntroDescription(tr("This wizard generates an empty Qt4 project. "
                            "Add files to it later on by using the other wizards."));
 
-    addTargetsPage();
+    addTargetSetupPage();
 
     foreach (QWizardPage *p, extensionPages)
         addPage(p);
diff --git a/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.cpp b/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.cpp
index 0f3959b1883158f9fb072e3b29f23e898b8fb2bb..2155af9da4346b30c430dddf6eca6fb0eefdbdc7 100644
--- a/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.cpp
+++ b/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.cpp
@@ -62,7 +62,7 @@ GuiAppWizardDialog::GuiAppWizardDialog(const QString &templateName,
          "and includes an empty widget."));
 
     addModulesPage();
-    addTargetsPage();
+    addTargetSetupPage();
 
     m_filesPage->setFormInputCheckable(true);
     m_filesPage->setClassTypeComboVisible(false);
@@ -110,12 +110,11 @@ GuiAppParameters GuiAppWizardDialog::parameters() const
     rc.formFileName = m_filesPage->formFileName();
     rc.designerForm =  m_filesPage->formInputChecked();
     rc.isMobileApplication = true;
-    QSet<QString> targets = selectedTargets();
-    if (targets.contains(QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID))) {
+    if (isTargetSelected(QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID))) {
         rc.widgetWidth = 800;
         rc.widgetHeight = 480;
-    } else if (targets.contains(QLatin1String(Constants::S60_DEVICE_TARGET_ID)) ||
-               targets.contains(QLatin1String(Constants::S60_EMULATOR_TARGET_ID))) {
+    } else if (isTargetSelected(QLatin1String(Constants::S60_DEVICE_TARGET_ID)) ||
+               isTargetSelected(QLatin1String(Constants::S60_EMULATOR_TARGET_ID))) {
         rc.widgetWidth = 360;
         rc.widgetHeight = 640;
     } else {
diff --git a/src/plugins/qt4projectmanager/wizards/librarywizarddialog.cpp b/src/plugins/qt4projectmanager/wizards/librarywizarddialog.cpp
index 2f396f4c0a13b99f9f3986ca113dbb43fe9311b7..dad6cff56ad847a506ec8bdbe8f7b47c80919573 100644
--- a/src/plugins/qt4projectmanager/wizards/librarywizarddialog.cpp
+++ b/src/plugins/qt4projectmanager/wizards/librarywizarddialog.cpp
@@ -146,7 +146,7 @@ LibraryWizardDialog::LibraryWizardDialog(const QString &templateName,
     // Use the intro page instead, set up initially
     setIntroDescription(tr("This wizard generates a C++ library project."));
 
-    m_targetPageId = addTargetsPage();
+    m_targetPageId = addTargetSetupPage();
     m_modulesPageId = addModulesPage();
 
     m_filesPage->setNamespacesEnabled(true);
diff --git a/src/plugins/qt4projectmanager/wizards/qtwizard.cpp b/src/plugins/qt4projectmanager/wizards/qtwizard.cpp
index 66f046304c1da932165f3752e38166da95f4d004..3e84b864c99ce335904561f1b12e3b3dfc778697 100644
--- a/src/plugins/qt4projectmanager/wizards/qtwizard.cpp
+++ b/src/plugins/qt4projectmanager/wizards/qtwizard.cpp
@@ -30,10 +30,11 @@
 #include "qtwizard.h"
 
 #include "qt4project.h"
+#include "qt4projectmanager.h"
 #include "qt4projectmanagerconstants.h"
 #include "qt4target.h"
 #include "modulespage.h"
-#include "targetspage.h"
+#include "targetsetuppage.h"
 
 #include <coreplugin/icore.h>
 #include <cpptools/cpptoolsconstants.h>
@@ -164,7 +165,7 @@ QWizard *CustomQt4ProjectWizard::createWizardDialog(QWidget *parent,
     initProjectWizardDialog(wizard, defaultPath, extensionPages);
     if (wizard->pageIds().contains(targetPageId))
         qWarning("CustomQt4ProjectWizard: Unable to insert target page at %d", int(targetPageId));
-    wizard->addTargetsPage(QSet<QString>(), targetPageId);
+    wizard->addTargetSetupPage(QSet<QString>(), targetPageId);
     return wizard;
 }
 
@@ -182,7 +183,7 @@ void CustomQt4ProjectWizard::registerSelf()
 BaseQt4ProjectWizardDialog::BaseQt4ProjectWizardDialog(bool showModulesPage, QWidget *parent) :
     ProjectExplorer::BaseProjectWizardDialog(parent),
     m_modulesPage(0),
-    m_targetsPage(0)
+    m_targetSetupPage(0)
 {
     init(showModulesPage);
 }
@@ -192,15 +193,15 @@ BaseQt4ProjectWizardDialog::BaseQt4ProjectWizardDialog(bool showModulesPage,
                                                        int introId, QWidget *parent) :
     ProjectExplorer::BaseProjectWizardDialog(introPage, introId, parent),
     m_modulesPage(0),
-    m_targetsPage(0)
+    m_targetSetupPage(0)
 {
     init(showModulesPage);
 }
 
 BaseQt4ProjectWizardDialog::~BaseQt4ProjectWizardDialog()
 {
-    if (m_targetsPage && !m_targetsPage->parent())
-        delete m_targetsPage;
+    if (m_targetSetupPage && !m_targetSetupPage->parent())
+        delete m_targetSetupPage;
     if (m_modulesPage && !m_modulesPage->parent())
         delete m_modulesPage;
 }
@@ -209,7 +210,6 @@ void BaseQt4ProjectWizardDialog::init(bool showModulesPage)
 {
     if (showModulesPage)
         m_modulesPage = new ModulesPage;
-    m_targetsPage = new TargetsPage;
 }
 
 int BaseQt4ProjectWizardDialog::addModulesPage(int id)
@@ -223,18 +223,26 @@ int BaseQt4ProjectWizardDialog::addModulesPage(int id)
     return addPage(m_modulesPage);
 }
 
-int BaseQt4ProjectWizardDialog::addTargetsPage(QSet<QString> targets, int id)
+int BaseQt4ProjectWizardDialog::addTargetSetupPage(QSet<QString> targets, int id)
 {
-    m_targetsPage->setValidTargets(targets);
-
-    if (!m_targetsPage->needToDisplayPage())
+    m_targetSetupPage = new TargetSetupPage;
+    QList<TargetSetupPage::ImportInfo> infos = TargetSetupPage::importInfosForKnownQtVersions(0);
+    if (!targets.isEmpty())
+        infos = TargetSetupPage::filterImportInfos(targets, infos);
+    m_targetSetupPage->setImportDirectoryBrowsingEnabled(false);
+    m_targetSetupPage->setShowLocationInformation(false);
+
+    if (infos.count() <= 1)
         return -1;
 
-    if (id >= 0) {
-        setPage(id, m_targetsPage);
-        return id;
-    }
-    return addPage(m_targetsPage);
+    m_targetSetupPage->setImportInfos(infos);
+
+    if (id >= 0)
+        setPage(id, m_targetSetupPage);
+    else
+        id = addPage(m_targetSetupPage);
+
+    return id;
 }
 
 QString BaseQt4ProjectWizardDialog::selectedModules() const
@@ -269,18 +277,30 @@ void BaseQt4ProjectWizardDialog::setDeselectedModules(const QString &modules)
     }
 }
 
-void BaseQt4ProjectWizardDialog::writeUserFile(const QString &proFileName) const
+bool BaseQt4ProjectWizardDialog::writeUserFile(const QString &proFileName) const
+{
+    if (!m_targetSetupPage)
+        return false;
+
+    Qt4Manager *manager = ExtensionSystem::PluginManager::instance()->getObject<Qt4Manager>();
+    Q_ASSERT(manager);
+
+    Qt4Project *pro = new Qt4Project(manager, proFileName);
+    bool success = m_targetSetupPage->setupProject(pro);
+    if (success)
+        pro->saveSettings();
+    delete pro;
+    return success;
+}
+
+bool BaseQt4ProjectWizardDialog::setupProject(Qt4Project *project) const
 {
-    if (m_targetsPage)
-        m_targetsPage->writeUserFile(proFileName);
+    return m_targetSetupPage->setupProject(project);
 }
 
-QSet<QString> BaseQt4ProjectWizardDialog::selectedTargets() const
+bool BaseQt4ProjectWizardDialog::isTargetSelected(const QString &targetid) const
 {
-    QSet<QString> targets;
-    if (m_targetsPage)
-        targets = m_targetsPage->selectedTargets();
-    return targets;
+    return m_targetSetupPage->isTargetSelected(targetid);
 }
 
 QSet<QString> BaseQt4ProjectWizardDialog::desktopTarget()
diff --git a/src/plugins/qt4projectmanager/wizards/qtwizard.h b/src/plugins/qt4projectmanager/wizards/qtwizard.h
index 760a72095da0ee2bcc6d498caa785d1cc13acb88..c5e0d9a72c113104733bbcc170bc9cca87df33c8 100644
--- a/src/plugins/qt4projectmanager/wizards/qtwizard.h
+++ b/src/plugins/qt4projectmanager/wizards/qtwizard.h
@@ -39,10 +39,13 @@
 #include <QtCore/QSet>
 
 namespace Qt4ProjectManager {
+
+class Qt4Project;
+
 namespace Internal {
 
 class ModulesPage;
-class TargetsPage;
+class TargetSetupPage;
 
 /* Base class for wizard creating Qt projects using QtProjectParameters.
  * To implement a project wizard, overwrite:
@@ -125,7 +128,7 @@ public:
     virtual ~BaseQt4ProjectWizardDialog();
 
     int addModulesPage(int id = -1);
-    int addTargetsPage(QSet<QString> targets = QSet<QString>(), int id = -1);
+    int addTargetSetupPage(QSet<QString> targets = QSet<QString>(), int id = -1);
 
     static QSet<QString> desktopTarget();
 
@@ -135,14 +138,15 @@ public:
     QString deselectedModules() const;
     void setDeselectedModules(const QString &);
 
-    void writeUserFile(const QString &proFileName) const;
-    QSet<QString> selectedTargets() const;
+    bool writeUserFile(const QString &proFileName) const;
+    bool setupProject(Qt4Project *project) const;
+    bool isTargetSelected(const QString &targetid) const;
 
 private:
     inline void init(bool showModulesPage);
 
     ModulesPage *m_modulesPage;
-    TargetsPage *m_targetsPage;
+    TargetSetupPage *m_targetSetupPage;
     QString m_selectedModules;
     QString m_deselectedModules;
 };
diff --git a/src/plugins/qt4projectmanager/wizards/targetspage.cpp b/src/plugins/qt4projectmanager/wizards/targetspage.cpp
deleted file mode 100644
index c4bf2c186e785e4bd678ab3251b90feed8ea2ec0..0000000000000000000000000000000000000000
--- a/src/plugins/qt4projectmanager/wizards/targetspage.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#include "targetspage.h"
-
-#include "qt4projectmanager/qt4project.h"
-#include "qt4projectmanager/qt4projectmanager.h"
-#include "qt4projectmanager/qt4target.h"
-#include "qt4projectmanager/qtversionmanager.h"
-#include "qt4projectmanager/qt4projectmanagerconstants.h"
-
-#include <extensionsystem/pluginmanager.h>
-
-#include <QtCore/QSet>
-#include <QtCore/QString>
-
-#include <QtGui/QTreeWidget>
-#include <QtGui/QLabel>
-#include <QtGui/QLayout>
-
-using namespace Qt4ProjectManager::Internal;
-
-TargetsPage::TargetsPage(QWidget *parent)
-    : QWizardPage(parent)
-{
-    setTitle(tr("Choose Qt versions"));
-
-    QVBoxLayout *vbox = new QVBoxLayout(this);
-
-    setTitle(tr("Select required Qt versions"));
-    QLabel *label = new QLabel(tr("Select the Qt versions to use in your project."), this);
-    label->setWordWrap(true);
-    vbox->addWidget(label);
-
-    m_treeWidget = new QTreeWidget(this);
-    m_treeWidget->setHeaderHidden(true);
-    vbox->addWidget(m_treeWidget);
-
-    QtVersionManager *vm = QtVersionManager::instance();
-    QStringList targets = vm->supportedTargetIds().toList();
-    qSort(targets.begin(), targets.end());
-
-    Qt4TargetFactory factory;
-
-    foreach (const QString &t, targets) {
-        QTreeWidgetItem *targetItem = new QTreeWidgetItem(m_treeWidget);
-        targetItem->setText(0, factory.displayNameForId(t));
-        targetItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
-        targetItem->setData(0, Qt::UserRole, t);
-        targetItem->setExpanded(true);
-
-        foreach (QtVersion *v, vm->versionsForTargetId(t)) {
-            QTreeWidgetItem *versionItem = new QTreeWidgetItem(targetItem);
-            versionItem->setText(0, v->displayName());
-            versionItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
-            versionItem->setData(0, Qt::UserRole, v->uniqueId());
-            versionItem->setCheckState(0, Qt::Unchecked);
-        }
-    }
-
-    connect(m_treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
-            this, SLOT(itemWasChanged()));
-
-    emit completeChanged();
-}
-
-void TargetsPage::setValidTargets(const QSet<QString> &targets)
-{
-    if (targets.isEmpty())
-        return;
-
-    for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) {
-        QTreeWidgetItem *currentTargetItem = m_treeWidget->topLevelItem(i);
-        QString currentTarget = currentTargetItem->data(0, Qt::UserRole).toString();
-        if (targets.contains(currentTarget))
-            currentTargetItem->setHidden(false);
-        else
-            currentTargetItem->setHidden(true);
-    }
-
-    // Make sure we have something checked!
-    if (selectedTargets().isEmpty()) {
-        for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) {
-            QTreeWidgetItem *currentTargetItem = m_treeWidget->topLevelItem(i);
-            QString currentTarget = currentTargetItem->data(0, Qt::UserRole).toString();
-            if (targets.contains(currentTarget) && currentTargetItem->childCount() >= 1) {
-                currentTargetItem->child(0)->setCheckState(0, Qt::Checked);
-                break;
-            }
-        }
-    }
-    emit completeChanged();
-}
-
-QSet<QString> TargetsPage::selectedTargets() const
-{
-    QSet<QString> result;
-    for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) {
-        QTreeWidgetItem * targetItem = m_treeWidget->topLevelItem(i);
-        QString target = targetItem->data(0, Qt::UserRole).toString();
-
-        QList<int> versions = selectedQtVersionIdsForTarget(target);
-        if (!versions.isEmpty())
-            result.insert(target);
-    }
-    return result;
-}
-
-QList<int> TargetsPage::selectedQtVersionIdsForTarget(const QString &t) const
-{
-    QList<int> result;
-    for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) {
-        QTreeWidgetItem * current = m_treeWidget->topLevelItem(i);
-        QString target = current->data(0, Qt::UserRole).toString();
-        if (t != target || current->isHidden())
-            continue;
-
-        for (int j = 0; j < current->childCount(); ++j) {
-            QTreeWidgetItem * child = current->child(j);
-            if (child->checkState(0) != Qt::Checked)
-                continue;
-            result.append(child->data(0, Qt::UserRole).toInt());
-        }
-    }
-    return result;
-}
-
-void TargetsPage::itemWasChanged()
-{
-    emit completeChanged();
-}
-
-bool TargetsPage::isComplete() const
-{
-    return !selectedTargets().isEmpty();
-}
-
-bool TargetsPage::needToDisplayPage() const
-{
-    int targetCount = 0;
-    for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) {
-        QTreeWidgetItem * current = m_treeWidget->topLevelItem(i);
-        if (current->isHidden())
-            continue;
-        ++targetCount;
-        if (targetCount > 1)
-            return true;
-
-        if (current->childCount() > 1)
-            return true;
-    }
-    return false;
-}
-
-void TargetsPage::writeUserFile(const QString &proFileName) const
-{
-    Qt4Manager *manager = ExtensionSystem::PluginManager::instance()->getObject<Qt4Manager>();
-    Q_ASSERT(manager);
-
-    Qt4Project *pro = new Qt4Project(manager, proFileName);
-    if (setupProject(pro))
-        pro->saveSettings();
-    delete pro;
-}
-
-bool TargetsPage::setupProject(Qt4ProjectManager::Qt4Project *project) const
-{
-    if (!project)
-        return false;
-
-    // Generate user settings:
-    QSet<QString> targets = selectedTargets();
-    if (targets.isEmpty())
-        return false;
-
-    QtVersionManager *vm = QtVersionManager::instance();
-
-    foreach (const QString &targetId, targets) {
-        QList<int> versionIds = selectedQtVersionIdsForTarget(targetId);
-        QList<QtVersion *> versions;
-        foreach (int id, versionIds)
-            versions.append(vm->version(id));
-        Qt4Target * target = project->targetFactory()->create(project, targetId, versions);
-        project->addTarget(target);
-    }
-    return true;
-}
diff --git a/src/plugins/qt4projectmanager/wizards/targetspage.h b/src/plugins/qt4projectmanager/wizards/targetspage.h
deleted file mode 100644
index 15629d42e410f0561f1922b6590c62f9256c244a..0000000000000000000000000000000000000000
--- a/src/plugins/qt4projectmanager/wizards/targetspage.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#ifndef TARGETSPAGE_H
-#define TARGETSPAGE_H
-
-#include <QtCore/QList>
-#include <QtCore/QSet>
-#include <QtCore/QString>
-
-#include <QtGui/QWizard>
-
-QT_BEGIN_NAMESPACE
-class QTreeWidget;
-QT_END_NAMESPACE
-
-namespace Qt4ProjectManager {
-class Qt4Project;
-
-namespace Internal {
-
-class TargetsPage : public QWizardPage
-{
-    Q_OBJECT
-
-public:
-    explicit TargetsPage(QWidget* parent = 0);
-
-    void setValidTargets(const QSet<QString> &targets);
-
-    QSet<QString> selectedTargets() const;
-    QList<int> selectedQtVersionIdsForTarget(const QString &) const;
-
-    bool isComplete() const;
-
-    bool needToDisplayPage() const;
-
-    void writeUserFile(const QString &proFileName) const;
-    bool setupProject(Qt4Project *project) const;
-
-private slots:
-    void itemWasChanged();
-
-private:
-    QSet<QString> m_validTargets;
-    QTreeWidget * m_treeWidget;
-};
-
-} // namespace Internal
-} // namespace Qt4ProjectManager
-
-#endif // TARGETSPAGE_H
diff --git a/src/plugins/qt4projectmanager/wizards/testwizarddialog.cpp b/src/plugins/qt4projectmanager/wizards/testwizarddialog.cpp
index 24b774060abf2a6129394c08d86df0dcbc6ab20a..2f4969a1767e1194238f23c920871bf986c46a68 100644
--- a/src/plugins/qt4projectmanager/wizards/testwizarddialog.cpp
+++ b/src/plugins/qt4projectmanager/wizards/testwizarddialog.cpp
@@ -60,7 +60,7 @@ TestWizardDialog::TestWizardDialog(const QString &templateName,
     setWindowIcon(icon);
     setWindowTitle(templateName);
     setSelectedModules(QLatin1String("core testlib"), true);
-    addTargetsPage();
+    addTargetSetupPage();
     m_testPageId = addPage(m_testPage);
     m_modulesPageId = addModulesPage();
     foreach (QWizardPage *p, extensionPages)
diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp
index f323241a1877bd50d0afaece684ca67d799bb2ea..11bef468c91b5770a86c470cf41052a8f725a00b 100644
--- a/src/shared/cplusplus/Parser.cpp
+++ b/src/shared/cplusplus/Parser.cpp
@@ -854,12 +854,19 @@ bool Parser::parseTemplateArgumentList(TemplateArgumentListAST *&node)
             }
         }
 
+        if (_pool != _translationUnit->memoryPool()) {
+            MemoryPool *pool = _translationUnit->memoryPool();
+            TemplateArgumentListAST *template_argument_list = node;
+            for (TemplateArgumentListAST *iter = template_argument_list, **ast_iter = &node;
+                 iter; iter = iter->next, ast_iter = &(*ast_iter)->next)
+                *ast_iter = new (pool) TemplateArgumentListAST((iter->value) ? iter->value->clone(pool) : 0);
+        }
+
         _templateArgumentList.insert(std::make_pair(start, TemplateArgumentListEntry(start, cursor(), node)));
         return true;
     }
 
     _templateArgumentList.insert(std::make_pair(start, TemplateArgumentListEntry(start, cursor(), 0)));
-
     return false;
 }
 
diff --git a/tests/auto/qml/qmldesigner/coretests/testcore.cpp b/tests/auto/qml/qmldesigner/coretests/testcore.cpp
index 037ce1ae1aef9a3a03b2c1f46b7bab513037266d..7878667a1b35e9b9aa3bd6243bc32da91a729ca7 100644
--- a/tests/auto/qml/qmldesigner/coretests/testcore.cpp
+++ b/tests/auto/qml/qmldesigner/coretests/testcore.cpp
@@ -3192,6 +3192,30 @@ void TestCore::testMetaInfo()
 //    QVERIFY(graphicsWidgetInfo.hasProperty("enabled")); // from QGraphicsItem
 }
 
+void TestCore::testMetaInfoEnums()
+{
+    QScopedPointer<Model> model(Model::create("Qt/Text"));
+    QVERIFY(model.data());
+
+    QScopedPointer<TestView> view(new TestView);
+    QVERIFY(view.data());
+    model->attachView(view.data());
+
+    QCOMPARE(view->rootModelNode().metaInfo().typeName(), QString("Qt/Text"));
+
+    QVERIFY(view->rootModelNode().metaInfo().hasProperty("transformOrigin"));
+
+    QVERIFY(view->rootModelNode().metaInfo().property("transformOrigin").isEnumType());
+    QCOMPARE(view->rootModelNode().metaInfo().property("transformOrigin").type(), QLatin1String("TransformOrigin"));
+    QVERIFY(view->rootModelNode().metaInfo().property("transformOrigin").enumerator().elementNames().contains(QLatin1String("Bottom")));
+    QVERIFY(view->rootModelNode().metaInfo().property("transformOrigin").enumerator().elementNames().contains(QLatin1String("Top")));
+
+    QVERIFY(view->rootModelNode().metaInfo().property("horizontalAlignment").isEnumType());
+    QCOMPARE(view->rootModelNode().metaInfo().property("horizontalAlignment").type(), QLatin1String("HAlignment"));
+    QVERIFY(view->rootModelNode().metaInfo().property("horizontalAlignment").enumerator().elementNames().contains(QLatin1String("AlignLeft")));
+    QVERIFY(view->rootModelNode().metaInfo().property("horizontalAlignment").enumerator().elementNames().contains(QLatin1String("AlignRight")));
+}
+
 void TestCore::testMetaInfoDotProperties()
 {
     QScopedPointer<Model> model(Model::create("Qt/Text"));
diff --git a/tests/auto/qml/qmldesigner/coretests/testcore.h b/tests/auto/qml/qmldesigner/coretests/testcore.h
index 8a04fe3f18f146331f84b1283deb1f426f9bbb6c..68e2f761e55c5b6ca00f6ce28b508511c6392c01 100644
--- a/tests/auto/qml/qmldesigner/coretests/testcore.h
+++ b/tests/auto/qml/qmldesigner/coretests/testcore.h
@@ -72,6 +72,7 @@ private slots:
     // unit tests MetaInfo, NodeMetaInfo, PropertyMetaInfo
     //
     void testMetaInfo();
+    void testMetaInfoEnums();
     void testMetaInfoDotProperties();
     void testMetaInfoListProperties();