diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000000000000000000000000000000000000..3abc8f844dafe326d60f99b36af4df1f43e560b9
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "qbs"]
+	path = src/shared/qbs
+	url = ../../qt-labs/qbs.git
diff --git a/dist/changes-2.7.0 b/dist/changes-2.7.0
index e09b77f5f0f0daca43a291a8ac279ff6daff42cd..477b90fd3e6a03dac92c68ccc710e24732274f31 100644
--- a/dist/changes-2.7.0
+++ b/dist/changes-2.7.0
@@ -1,6 +1,6 @@
 Qt Creator version 2.7 contains bug fixes and new features.
 
-There is a total of about 1350 changes by 63 individual contributors.
+There is a total of about 1350 changes by 64 individual contributors.
 
 The most important changes are listed in this document. For a complete
 list of changes, see the Git log for the Qt Creator sources that
@@ -16,6 +16,9 @@ General
    * Implemented hiding of Mode tab icons when they become too small
      (QTCREATORBUG-7879)
    * Introduced general suppression mechanism for repeating messages
+   * Implemented filtering examples by Qt version in Welcome mode
+     (QTCREATORBUG-8377)
+   * Added highlighting of examples in Welcome mode (QTCREATORBUG-8459)
 
 Editing
    * Fixed visual whitespace highlighting
@@ -163,7 +166,7 @@ Help
 Qt Designer
 
 Qt Quick Designer
-   * Provided initial support for QML 2
+   * Provided initial support for Qt Quick 2
    * Fixed imports
    * Fixed crash (QTCREATORBUG-8399)
    * Built qml2puppet by default for Qt 5
@@ -206,15 +209,11 @@ FakeVim
    * Improved code completion in insert and replace modes
    * ... and _a lot_ more. Special thanks to Lukas here.
 
-BinEditor:
+BinEditor
    * Fixed selection edge cases (QTCREATORBUG-5209)
    * Fixed Ctrl+Home/End navigation
    * Added selection using Shift+LeftClick
 
-WelcomePage:
-   * Added combobox to filter examples by Qt version (QTCREATORBUG-8377)
-   * Added highlighting of examples (QTCREATORBUG-8459)
-
 Platform Specific
 
 Mac
@@ -232,15 +231,19 @@ Remote Linux Support
    * Removed dependency on Qt4ProjectManager
    * Implemented SSH tunneling as specified in RFC 4254
 
+Madde
+   * Disabled plugin by default
+
 QNX
-   * Used QtQuick2ApplicationViewer for BB Quick 2 app templates
-   * Used QML_INSTALL_QML variable for BB Qt 5 app templates
+   * Used QtQuick2ApplicationViewer for BlackBerry Qt Quick 2 application
+     templates
+   * Used QML_INSTALL_QML variable for BlackBerry Qt 5 application templates
    * Added bar-descriptor.xml to new project
    * Added templates for Cascades Applications
-   * Added BlackBerry settings page
-   * Fixes sysroot path valus on BB10 generated kits
+   * Added BlackBerry options
+   * Fixed sysroot path values in kits generated by BlackBerry 10 NDK installer
    * Set default device host IP for physical device
-   * Added editor for Bar descriptor file
+   * Added editor for BAR descriptor file
 
 Android
    * Fixed ps output processing for busybox
@@ -248,8 +251,7 @@ Android
 
 Task List
    * Implemented removal of single tasks from task list
-   * Added keyboard shortcuts for actions
-
+   * Added keyboard shortcuts for actions in context menu in Issues pane
 
 Code Paster
    * Added command-line frontend
@@ -259,13 +261,11 @@ Testing
 
 Tools
    * Improved ast2png when parsing declarators
-   * Created group/world files in SDKtool (QTCREATORBUG-8458)
+   * Fixed file permissions set by the Qt SDK installer that caused an error
+     to be displayed in Qt Creator (QTCREATORBUG-8458)
 
 Packaging
 
-Madde
-   * Plugin is now disabled by default
-
 Credits for these changes go to:
 
 Aaron McCarthy
@@ -298,6 +298,7 @@ Jörg Bornemann
 J-P Nurmi
 Kai Köhne
 Knut Petter Svendsen
+Leena Miettinen
 Lukas Holecek
 Marcel Krems
 Marco Bubke
diff --git a/doc/api/qtcreator-documentation.qdoc b/doc/api/qtcreator-documentation.qdoc
index 3af07eca0a254a95421e5bff3ec10a8f6f0275fb..90fdcda6b79547241ec9a19209a354d2256e73b3 100644
--- a/doc/api/qtcreator-documentation.qdoc
+++ b/doc/api/qtcreator-documentation.qdoc
@@ -151,13 +151,64 @@
     You can illustrate your documentation by using screen shots, diagrams, and
     other images.
 
+    \section2 Taking Screen Shots
+
+    \QC has the native look and feel on Windows, Linux, and Mac OS, and
+    therefore, screen shots can end up looking very different, depending on who
+    takes them and which system they use. To try to preserve a consistent look
+    and feel in the \QC Manual, observe the guidelines listed in this section
+    when taking screen shots.
+
+    To make the images look similar regardless of the operating system they were
+    taken on, you are asked to adjust their size to 75%. This makes the screen
+    shots hard to read, but they are provided more as reassurance for users that
+    they are in the correct place in the UI than as an actual source of
+    information. To make sure that no important information is lost, always
+    place example values also in the text.
+
+    \list
+
+        \li Use the screen resolution of 1024x768 (this is available on all
+            screens).
+
+        \li Use the aspect ratio of 4:3.
+
+        \li Open the application in the maximum size on full screen.
+
+        \li Use your favorite tool to take the screen shot.
+
+        \li Include only the part of the screen that you need (you can crop the
+            image also in the screen capture tool).
+
+        \li In the screen capture tool, open the screen shot and adjust its size
+            to 75%.
+
+        \li To highlight parts of the screen shot, use the images of numbers
+            that are stored in \c{doc\images\numbers} in the \QC repository.
+
+        \li Before you submit the images to the repository, optimize them to
+            save space.
+
+    \endlist
+
+    \section2 Optimizing Images
+
     Save images in the PNG format in the \QC project folder in the
     \c {doc\images} folder. Binary images can easily add megabytes to the Git
     history. To keep the history as small as possible, the Git post-commit hooks
     remind you to try to keep image size below 50 kilobytes. To achieve this
     goal, crop images so that only relevant information is visible in them.
-    Before committing images, optimize them by using the Radical Image
-    Optimization Tool (RIOT).
+    Before committing images, optimize them by using an image optimization tool.
+
+    Optimization should not visibly reduce image quality. If it does, do not do
+    it. You can use the Radical Image Optimization Tool (RIOT) on Windows (very
+    efficient) or ImageOptim on Mac OS (much less efficient), or some other tool
+    available on Linux.
+
+    With ImageOptim, you simply drag and drop the image files to the
+    application. The following section describes the settings to use for RIOT.
+
+    \section3 Using RIOT
 
     Use the \c {\image} and \c {\inlineimage} QDoc commands to refer to images
     from the text. You do not need to add paths to image names. For example:
@@ -204,28 +255,33 @@
     troubleshooting.
 
     The content and formatting of documentation are separated in QDoc.
-    Separate style sheets are used to generate help files for \QC and online
+    The documentation configuration, style sheets, and templates have
+    changed over time, so they differ between Qt and \QC versions. In Qt 4,
+    separate style sheets are used to generate help files for \QC and online
     documentation for the Web.
 
-    The documentation configuration, style sheets, and build process have
-    changed over time, so they differ between Qt and \QC versions. To use the
-    online style, use QDoc from Qt 4.7.4 to build the docs. To use the \QC help
-    style, use QDoc from Qt 4.8, or later.
+    In Qt 5, only one set of templates is used, as defined by the
+    \c {qt5\qtbase\doc\global\qt-module-defaults.qdocconf} configuration file.
+    It is fetched from Qt sources by adding the following line to the qdocconf
+    file:
+
+    \c {include ($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)}
+
+    To pick the Qt to use, run qmake from either Qt 4 or Qt 5.
 
     To build documentation for the sources from the qtcreator master branch, use
     build scripts defined in the doc.pri file. To build all \QC docs in the
     help format and to create help files (.qch), enter the following build
-    commands from the project folder:
+    commands from the project folder (after running qmake):
 
     \list
 
         \o  nmake docs (on Windows)
-        \o  make docs (on Linux)
+        \o  make docs (on Linux and Mac OS)
 
     \endlist
 
-    The following options generate HTML that uses the help style, and therefore
-    require QDoc from Qt 4.8 or later:
+    Besides \c docs, you have the following options:
 
     \list
 
@@ -241,13 +297,6 @@
         \o  dev_qch_docs - build Extending \QC Manual in help format and
             generate a help file (.qch)
 
-    \endlist
-
-    The following options generate HTML that uses the online style (they do not
-    generate a help file), and therefore require QDoc from Qt 4.7.4:
-
-    \list
-
         \o  docs_online - build \QC Manual and Extending \QC Manual in online
             format
 
diff --git a/doc/fixnavi.pl b/doc/fixnavi.pl
index 97357890597505abe0cd6b061a317ef7c51fafcf..3ce862beb8a7cb43199c44a5f8cc8ba0c3f3f3a0 100755
--- a/doc/fixnavi.pl
+++ b/doc/fixnavi.pl
@@ -78,7 +78,7 @@ for my $file (@files) {
         } elsif ($intoc) {
             if (/^\h*\\endlist/) {
                 $intoc--;
-            } elsif (!$skipping && /^\h*\\o\h+\\l\h*{(.*)}$/) {
+            } elsif (!$skipping && /^\h*\\li\h+\\l\h*{(.*)}$/) {
                 push @toc, $1;
             }
         } elsif ($inhdr) {
diff --git a/doc/images/qtcreator-vcs-commit.png b/doc/images/qtcreator-vcs-commit.png
index 32c05823002f149cf9e0fc7a166d0deeee4b9a42..a55f92b1d280fade65f2afa63024a78fbd503a03 100644
Binary files a/doc/images/qtcreator-vcs-commit.png and b/doc/images/qtcreator-vcs-commit.png differ
diff --git a/doc/images/qtcreator-vcs-gitbranch.png b/doc/images/qtcreator-vcs-gitbranch.png
index decbcadc76a3d9ed0ee9807107bbb9d874309509..26aac18326f16417765f0e9701fe10ee2da5e223 100644
Binary files a/doc/images/qtcreator-vcs-gitbranch.png and b/doc/images/qtcreator-vcs-gitbranch.png differ
diff --git a/doc/src/android/androiddev.qdoc b/doc/src/android/androiddev.qdoc
index ab5f2614e685f3491d364b426a4f974ad1d7cdb1..fe99efddb1b1368bb5bd7839e92ad3aa26b6c595 100644
--- a/doc/src/android/androiddev.qdoc
+++ b/doc/src/android/androiddev.qdoc
@@ -21,7 +21,7 @@
     \contentspage index.html
     \previouspage creator-connecting-mobile.html
     \page creator-developing-android.html
-    \nextpage creator-developing-generic-linux.html
+    \nextpage creator-developing-bb10.html
 
     \title Connecting Android Devices
 
diff --git a/doc/src/android/deploying-android.qdoc b/doc/src/android/deploying-android.qdoc
index bf18592d42d2306de10f3d4c6e99022e67d8ff5d..e0716542930142e4b6a3762e4221b1d5deadb093 100644
--- a/doc/src/android/deploying-android.qdoc
+++ b/doc/src/android/deploying-android.qdoc
@@ -21,7 +21,7 @@
     \contentspage index.html
     \previouspage creator-deployment.html
     \page creator-deploying-android.html
-    \nextpage creator-deployment-maemo.html
+    \nextpage creator-deployment-bb10.html
 
     \title Deploying Applications to Android Devices
 
diff --git a/doc/src/howto/creator-vcs.qdoc b/doc/src/howto/creator-vcs.qdoc
index f4e07fbc2ad76e63416487deaf7a531a7c21f295..b5ffc9b7ce7c0d75c830716061898787ed09cca9 100644
--- a/doc/src/howto/creator-vcs.qdoc
+++ b/doc/src/howto/creator-vcs.qdoc
@@ -214,7 +214,7 @@
     version identifier at the beginning of a line and choose one of the
     revisions shown at the bottom of the context menu. This allows you to
     navigate through the history of the file and obtain previous versions of
-    it. It also works for Git and Mercurial using SHA's.
+    it. It also works for Git and Mercurial using SHA-1.
 
     The same context menu is available when right-clicking on a version
     identifier in the file log view of a single file.
@@ -255,16 +255,21 @@
 
     \list
 
-        \li \gui{Undo Unstaged Changes} reverts all changes and resets the
-            working directory to the state of the index.
+        \li \gui Git > \gui {Current File} > \gui{Undo Unstaged Changes} reverts
+            all changes and resets the working directory to the state of the
+            index.
 
-        \li \gui{Undo Uncommitted Changes} reverts all changes, discarding the
+        \li \gui Git > \gui {Current File} > \gui {Undo Uncommitted Changes}
+            reverts all changes, discarding the
             index. This returns your working copy to the state it was in right
             after the last commit.
 
-        \li \gui{Reset...} opens a dialog where you can select the SHA1 to reset
-            the working directory to. This is useful after applying patches for
-            review, for example.
+        \li \gui Git > \gui {Local Repository} > \gui Reset opens a dialog
+            where you can select the SHA-1 to reset the working directory to.
+            This is useful after applying patches for review, for example. You
+            can choose between a \gui {Soft Reset} that does not touch the index
+            file nor the working tree at all and a \gui {Hard Reset} that
+            discards all changes to tracked files in working tree.
 
     \endlist
 
@@ -351,61 +356,40 @@
     tool for projects that use Git. You can apply and check out changes from
     Gerrit in \QC 2.6 and later.
 
-    The \gui Git submenu contains the following additional items:
+    \section3 Working with the Current File
 
-    \table
-        \header
-            \li Menu Item
-            \li Description
-        \row
-            \li \gui {Patch > Apply from Editor/Apply from File}
-            \li Patches are rewriting instructions that can be applied to a set
-                of files. You can either apply a patch file that is open in \QC
-                or select the patch file to apply from the file system.
-        \row
-            \li \gui{Pull}
-            \li Pull changes from the remote repository. If there are locally
-                modified files, you are prompted to stash those changes. Select
-                \gui{Tools > Options > Version Control > Git} and select the
-                \gui {Pull with rebase} check box to perform a rebase operation
-                while pulling.
+    In addition to the standard version control system functions, you can
+    select \gui Tools > \gui Git > \gui {Current File} > \gui {Stage File for
+    Commit} to mark a new or modified file for committing to the repository.
 
-        \row
-            \li \gui{Clean/Clean Project}
-            \li All files that are not under version control (with the exception
-                of patches and project files) are displayed in the \gui {Clean
-                Repository} dialog. Select the files to delete and click
-                \gui Delete. This allows you to clean a build completely.
-        \row
-            \li \gui{Launch gitk}
-            \li Start the commit viewer for Git, gitk.
-        \row
-            \li \gui{Branches}
-            \li Manage local and remote branches.
-        \row
-            \li \gui Remotes
-            \li Manage remote repositories available in Git.
-        \row
-            \li \gui {Stage File for Commit}
-            \li Mark new or modified files for committing to the repository.
-                To undo this function, select \gui {Unstage File from Commit}.
-        \row
-            \li \gui{Show Commit}
-            \li Select a commit to view. Enter the SHA of the commit
-                in the \gui Change field.
-        \row
-            \li \gui Stash
-            \li Store local changes temporarily.
-        \row
-            \li \gui{Amend Last Commit}
-            \li Revert the last commit.
-        \row
-            \li \gui Gerrit
-            \li View, apply, and check out changes from Gerrit.
+    To undo this function, select \gui {Unstage File from Commit}.
 
-    \endtable
+    \section3 Working with the Current Project
 
-    \section3 Working with Branches
+    In addition to the standard version control system functions, you can
+    select \gui Tools > \gui Git > \gui {Current Project} > \gui {Clean Project}
+    to clean the working directory. All files that are not under version control
+    are displayed in the \gui {Clean Repository} dialog. Ignored files are
+    deselected by default. Select the files to delete and click \gui Delete.
+
+    \section3 Working with Local Repositories
+
+    In addition to the standard version control system functions, you can
+    select \gui Tools > \gui Git > \gui {Local Repository} > \gui Clean to clean
+    the repository.
+
+    To show commits, select \gui Tools > \gui Git > \gui {Show Commit} and
+    select a commit to view. Enter the SHA-1 or reference of the commit in the
+    \gui Change field.
+
+    To apply latest changes to the last commit, select \gui Tools > \gui Git >
+    \gui {Local Repository} > \gui {Amend Last Commit}. You can also edit the
+    commit message.
+
+    The following sections describe how to manage local and remote branches,
+    apply patches, and use stashes.
+
+    \section4 Working with Branches
 
     To work with Git branches, select \gui{Branches}. The checked out branch
     is shown in bold and underlined in the list of branches. Double-click branch
@@ -419,15 +403,19 @@
         \header
             \li Menu Item
             \li Description
+        \row
+            \li \gui{Refresh}
+            \li Refresh the list of branches.
         \row
             \li \gui{Add}
             \li Create new tracking and non-tracking branches.
-        \row
-            \li \gui{Checkout}
-            \li Check out the selected branch and make it current.
         \row
             \li \gui{Remove}
             \li Remove a local branch. You cannot delete remote branches.
+        \row
+            \li \gui{Checkout}
+            \li Check out the selected branch and make it current. You can stash
+                changes you have made to tracked files.
         \row
             \li \gui{Diff}
             \li Show the differences between the selected and the current
@@ -436,14 +424,59 @@
             \li \gui{Log}
             \li Show the changes in a branch.
         \row
-            \li \gui{Refresh}
-            \li Refresh the list of branches.
+            \li \gui Merge
+            \li Join the development histories in two branches together.
+        \row
+            \li \gui Rebase
+            \li Copy local commits to the updated upstream head.
     \endtable
 
+    \section4 Applying Patches
+
+    Patches are rewriting instructions that can be applied to a set of files.
+    To apply a patch file that is open in \QC, select \gui Tools > \gui Git >
+    \gui {Local Repository} > \gui {Apply from Editor}.
+
+    To select the patch file to apply from the file system, select
+    \gui {Apply from File}.
+
+    \section4 Using Stashes
+
+    With Git, you can put your current set of changes onto a virtual shelf
+    called a \e stash. Stashes are useful, for example, to put aside a set of
+    changes to work on higher priority tasks or to pull in new chages from
+    another repository.
+
+    To stash all local changes, select \gui Tools > \gui Git >
+    \gui {Local Repository} > \gui Stash > \gui Stash. The working copy is reset
+    to the state it had after the last commit.
+
+    To display a dialog that shows all known stashes with options to restore,
+    display or delete them, select \gui Stashes.
+
+    To save a snapshot of your current work under a name for later reference,
+    select \gui {Stash Snapshot}. The working copy is unchanged. For example, if
+    you want to try something and find out later that it does not work, you can
+    discard the changes and return to the state of the snapshot.
+
+    To remove a single stashed state from the stash list and apply it on top of
+    the current working tree state, select \gui {Stash Pop}.
+
     \section3 Working with Remote Repositories
 
-    To manage remote repositories available in Git, select \gui{Remotes}.
-    Double-click the names and URLs of the remote repositories to edit them.
+    In addition to the standard version control system functions, you can
+    select \gui Tools > \gui Git > \gui {Remote Repository} > \gui Pull to
+    pull changes from the remote repository. If there are locally modified
+    files, you are prompted to stash the changes. Select \gui Tools >
+    \gui Options > \gui {Version Control} > \gui Git and then select the
+    \gui {Pull with rebase} check box to perform a rebase operation while
+    pulling.
+
+    \section4 Managing Remote Repositories
+
+    To manage remote repositories available in Git, select \gui Tools > \gui Git
+    > \gui {Remote Repository} > \gui{Manage Remotes}. Double-click the names
+    and URLs of the remote repositories to edit them.
 
     The following operations are supported:
 
@@ -466,43 +499,15 @@
             \li Refresh the list of remote repositories.
     \endtable
 
+    \section4 Using Git with Subversion
 
-    \section3 Using Stashes
-
-    With Git, you can put your current set of changes onto a virtual shelf
-    called a \e stash. Stashes are useful, for example, to put aside a set of
-    changes to work on higher priority tasks or to pull in new chages from
-    another repository.
-
-    \QC exposes this functionality in the \gui{Tools > Git > Stash} menu.
-
-    \table
-        \header
-            \li Menu Item
-            \li Description
-        \row
-            \li \gui{Stashes}
-            \li Display a dialog that shows all known stashes with options to
-                restore, display or delete them.
-        \row
-            \li \gui{Stash}
-            \li Stash all local changes. The working copy is then reset to
-                the state it had right after the last commit.
-        \row
-            \li \gui{Stash Snapshot}
-            \li Save a snapshot of your current work under a name for later
-                reference. The working copy is unchanged.
+    You can use Git as a client for a Subversion server. To fetch changes from a
+    Subversion repository to a Git repository, select \gui Tools > \gui Git >
+    \gui {Remote Repository} > \gui Subversion > \gui Fetch.
 
-                For example, if you want to try something and find out later
-                that it does not work, you can discard it and return to the
-                state of the snapshot.
-        \row
-            \li \gui{Stash Pop}
-            \li Remove a single stashed state from the stash list and apply it
-                on top of the current working tree state.
-    \endtable
+    To view the Git Subversion log, select \gui Log.
 
-    \section3 Reviewing Code with Gerrit
+    \section4 Reviewing Code with Gerrit
 
     If your Git project uses Gerrit for code reviews, you can view your changes
     in \QC.
@@ -521,13 +526,31 @@
 
     To apply the selected change to the top of your local repository, select
     \gui Apply. To remove the change after testing it, select \gui Tools >
-    \gui Git > \gui {Reset}. In the \gui {Undo Changes to} dialog, select the
+    \gui Git > \gui {Local Repository} > \gui Reset. In the
+    \gui {Undo Changes to} dialog, select the
     state to reset the working directory to, and then select \gui OK.
 
     To check out the change in a headless state, select \gui Checkout.
 
     To refresh the list of changes, select \gui Refresh.
 
+    \section3 Working with Git Tools
+
+    To start the commit viewer for Git, select \gui Tools > \gui Git >
+    \gui {Git Tools} > \gui Gitk. You can also start the tool to view commits in
+    the current document or in the folder that contains the current document.
+    To specify arguments for running Gitk, select \gui Tools > \gui Options >
+    \gui {Version Control} > \gui Git.
+
+    To use some other application for viewing Git history, such as GitX or
+    QGit viewer, select \gui Tools > \gui Options > \gui {Version Control} >
+    \gui Git and specify the path to the application executable in the
+    \gui {Command} field. To start the application, select \gui Tools > \gui Git
+    > \gui {Git Tools} > \gui {Repository Browser}.
+
+    To resolve merge conflicts, select \gui Tools > \gui Git > \gui {Git Tools}
+    > \gui {Merge Tool}.
+
     \section2 Using Additional Mercurial Functionality
 
     Mercurial is a free, distributed source control management tool.
diff --git a/doc/src/linux-mobile/creator-deployment-madde.qdoc b/doc/src/linux-mobile/creator-deployment-madde.qdoc
index 4c802b7874cba88fd8ded2d2194ed8e800f3032b..fdceddb5cab719cc8f022eeba2fcc2dbc8a94a68 100644
--- a/doc/src/linux-mobile/creator-deployment-madde.qdoc
+++ b/doc/src/linux-mobile/creator-deployment-madde.qdoc
@@ -24,7 +24,7 @@
 
 /*!
     \contentspage index.html
-    \previouspage creator-deploying-android.html
+    \previouspage creator-deployment-bb10.html
     \page creator-deployment-maemo.html
     \nextpage creator-deployment-qnx.html
 
diff --git a/doc/src/linux-mobile/linuxdev.qdoc b/doc/src/linux-mobile/linuxdev.qdoc
index ebd4d8f22e2e56af5699c305656bb19d1e356f75..f4accdcf0286d518aae090930c16103f7d1944ce 100644
--- a/doc/src/linux-mobile/linuxdev.qdoc
+++ b/doc/src/linux-mobile/linuxdev.qdoc
@@ -19,7 +19,7 @@
     /*!
 
     \contentspage index.html
-    \previouspage creator-developing-android.html
+    \previouspage creator-developing-bb10.html
     \page creator-developing-generic-linux.html
     \nextpage creator-developing-maemo.html
 
diff --git a/doc/src/linux-mobile/maemodev.qdoc b/doc/src/linux-mobile/maemodev.qdoc
index 4255c35116c77afb26da52ddbde8d81f63e61e74..143c46430d4b43aa59e481277d5f3d56e56246d6 100644
--- a/doc/src/linux-mobile/maemodev.qdoc
+++ b/doc/src/linux-mobile/maemodev.qdoc
@@ -36,6 +36,10 @@
     run, and deploy Maemo 5 applications as a part of the custom installation
     in the Qt 4 SDK online installer.
 
+    \note In \QC 2.7, and later, the Madde plugin that you need for Maemo
+    development is disabled by default. To enable it, select \gui Help >
+    \gui {About Plugins} > \gui {Device Support} > \gui Madde and restart \QC.
+
     \if defined(qcmanual)
     For more
     information about the Maemo 5 platform, see
diff --git a/doc/src/linux-mobile/meegodev.qdoc b/doc/src/linux-mobile/meegodev.qdoc
index 928e56e4b437870f54b3f9a93079546817ef3ab9..982f45e0ffd2fb2aeb175c7afbd95bb2b48b8edb 100644
--- a/doc/src/linux-mobile/meegodev.qdoc
+++ b/doc/src/linux-mobile/meegodev.qdoc
@@ -35,6 +35,10 @@
     to create, build, debug, run, and deploy Harmattan applications as part of
     the Qt 4 SDK.
 
+    \note In \QC 2.7, and later, the Madde plugin that you need for MeeGo
+    development is disabled by default. To enable it, select \gui Help >
+    \gui {About Plugins} > \gui {Device Support} > \gui Madde and restart \QC.
+
     \if defined(qcmanual)
     For more information about the Harmattan platform, see
     \l{http://library.developer.nokia.com/topic/MeeGo_1.2_Harmattan_API/html/guide/html/Developer_Library_Harmattan_overview_5dcf.html}
diff --git a/doc/src/overview/creator-deployment-overview.qdoc b/doc/src/overview/creator-deployment-overview.qdoc
index 4174b4f0fb740637bf3d600a5578ec7f0ce5d679..f2fcaefc51461a0f015b6fdc60bd3575d42df543 100644
--- a/doc/src/overview/creator-deployment-overview.qdoc
+++ b/doc/src/overview/creator-deployment-overview.qdoc
@@ -42,6 +42,11 @@
             When you deploy the application on an Android device, \QC copies
             the application files to the device. In addition, you can determine
             the Qt libraries to use.
+        \li  \l{Deploying Applications to BlackBerry 10 Devices}
+
+            When you deploy the application to a BlackBerry 10 device, \QC generates a
+            BAR package in the build directory and deploys it to the connected
+            device.
         \li \l{Deploying Applications to Linux-Based Devices}
 
             When you deploy the application on a Linux-based device, such
diff --git a/doc/src/overview/creator-mobile-targets.qdoc b/doc/src/overview/creator-mobile-targets.qdoc
index d7d92f785f7ab9caf66b85b038f4d2cbe36b589a..3eec3785a8d56607ea73c3a8714b34a6a2f93a6a 100644
--- a/doc/src/overview/creator-mobile-targets.qdoc
+++ b/doc/src/overview/creator-mobile-targets.qdoc
@@ -51,6 +51,13 @@
             Android version 1.6, or later. You must install the Qt for Android
             SDK to develop for Android devices.
 
+        \li \l{Connecting BlackBerry 10 Devices}
+
+            \QC enables you to develop, deploy and debug your Qt applications
+            on BlackBerry 10.
+            You need to install the BlackBerry 10 NDK which contains a pre-built Qt.
+            You also need either a BlackBerry 10 device or the simulator.
+
         \li \l{Connecting Embedded Linux Devices}
 
             If you have a tool chain for building applications for embedded
diff --git a/doc/src/qnx/creator-deployment-bb10.qdoc b/doc/src/qnx/creator-deployment-bb10.qdoc
new file mode 100644
index 0000000000000000000000000000000000000000..4ecfe9009d642409ea97a3a50027f8c374618485
--- /dev/null
+++ b/doc/src/qnx/creator-deployment-bb10.qdoc
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (C) 2011 - 2013 Research In Motion
+**
+** Contact: Research In Motion (blackberry-qt@qnx.com)
+** Contact: KDAB (info@kdab.com)
+**
+**
+** GNU Free Documentation License
+**
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of this
+** file.
+**
+**
+****************************************************************************/
+
+// **********************************************************************
+// NOTE: the sections are not ordered by their logical order to avoid
+// reshuffling the file each time the index order changes (i.e., often).
+// Run the fixnavi.pl script to adjust the links to the index order.
+// **********************************************************************
+
+/*!
+    \contentspage index.html
+    \previouspage creator-deploying-android.html
+    \page creator-deployment-bb10.html
+    \nextpage creator-deployment-maemo.html
+
+    \title Deploying Applications to BlackBerry 10 Devices
+
+    To deploy Qt applications to BlackBerry 10 devices:
+
+    \list 1
+        \li Create a new project. To create an application with the native BlackBerry 10 look and feel,
+        select \gui File > \gui {New File or Project} > \gui {BlackBerry Qt Gui Application} > \gui Choose.
+        \li Select a BlackBerry 10 Kit for either device or simulator.
+        \li \QC will generate an additional application descriptor file to enable the packaging process.
+        \li You can use the BAR descriptor editor to customize the appearance and behavior of the application.
+    \endlist
+
+    For more details please refer to the Qt-Project wiki page: \l {http://qt-project.org/wiki/BlackBerry} {http://qt-project.org/wiki/BlackBerry}.
+*/
diff --git a/doc/src/qnx/creator-developing-bb10.qdoc b/doc/src/qnx/creator-developing-bb10.qdoc
new file mode 100644
index 0000000000000000000000000000000000000000..5f7bdb11520b2a52209517788e8cd94b0616dee1
--- /dev/null
+++ b/doc/src/qnx/creator-developing-bb10.qdoc
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (C) 2011 - 2013 Research In Motion
+**
+** Contact: Research In Motion (blackberry-qt@qnx.com)
+** Contact: KDAB (info@kdab.com)
+**
+**
+** GNU Free Documentation License
+**
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of this
+** file.
+**
+**
+****************************************************************************/
+
+/*!
+    \contentspage index.html
+    \previouspage creator-developing-android.html
+    \page creator-developing-bb10.html
+    \nextpage creator-developing-generic-linux.html
+
+
+    \title Connecting BlackBerry 10 Devices
+
+    \QC provides a plugin that enables you to develop for QNX and BlackBerry 10 platforms.
+    This page explains the basic steps to develop for BlackBerry 10 using \QC.
+
+    The native BlackBerry 10 NDK includes Qt 4 (4.8.4 or newer) for both simulator (x86) and device (arm) targets available for development. Compared with the development for the PlayBook, Qt libraries are integrated in the BlackBerry 10 device firmware and can be used by Qt applications as shared libraries.
+
+    Before starting to develop for BlackBerry 10 you need to download the following tools:
+
+    \list
+        \li \l {https://developer.blackberry.com/native/} {The BlackBerry 10 Native SDK}
+        \li \l {https://developer.blackberry.com/native/} {The BlackBerry 10 Dev Alpha Simulator} if you do not have a BlackBerry DevAlpha device
+        \li \l {https://www.blackberry.com/SignedKeys/} {BlackBerry signing code keys}
+    \endlist
+
+
+    \section1 Setting Up BlackBerry 10 Environment in Qt Creator
+
+    To set up your BlackBerry 10 environment in \QC:
+
+    \list 1
+        \li Select \gui Tools > \gui Options > \gui BlackBerry > \gui NDK to set your NDK path.
+        \li Select \gui Tools > \gui Options > \gui BlackBerry > \gui Keys to register and create a developer certificate.
+        \li Select \gui Tools > \gui Options > \gui Devices > \gui Add > \gui {Blackberry Device} to add a BlackBerry Device. You can add either the physical device or the simulator.
+        \li Create and upload a debug token bar file when adding the device from the wizard.
+    \endlist
+
+    For more details please refer to the Qt-Project wiki page: \l {http://qt-project.org/wiki/BlackBerry} {http://qt-project.org/wiki/BlackBerry}.
+*/
diff --git a/doc/src/qtcreator.qdoc b/doc/src/qtcreator.qdoc
index 00a2beffc83e8f0179016cdd37a6199664c43f6f..a9ed1ccc5a5c0823fcb3c1a38751df61925382b4 100644
--- a/doc/src/qtcreator.qdoc
+++ b/doc/src/qtcreator.qdoc
@@ -150,7 +150,7 @@
             \li \l{Building and Running an Example}
             \li \l{Tutorials}
             \list
-                \li \l{Creating a Qt Quick Application}
+                \li \l{Creating a Qt Quick 1 Application}
                 \li \l{Creating a Qt Widget Based Application}
             \endlist
         \endlist
@@ -234,17 +234,18 @@
             \li \l{Deploying to Mobile Devices}
             \list
                 \li \l{Deploying Applications to Android Devices}
+                \li \l{Deploying BlackBerry 10 Devices}
                 \li \l{Deploying Applications to Linux-Based Devices}
                 \li \l{Deploying Applications to QNX Devices}
             \endlist
             \li \l{Connecting Mobile Devices}
             \list
                 \li \l{Connecting Android Devices}
+                \li \l{Connecting BlackBerry 10 Devices}
                 \li \l{Connecting Embedded Linux Devices}
                 \li \l{Connecting Maemo Devices}
                 \li \l{Connecting MeeGo Harmattan Devices}
                 \li \l{Connecting QNX Devices}
-
             \endlist
             \li \l{Customizing the Build Process}
             \li \l{Using Maemo or MeeGo Harmattan Emulator}
diff --git a/src/libs/libs.pro b/src/libs/libs.pro
index 9a1da2d4ebe980b581b3ae179c4ee5fabb63307f..4598fd4c8bbcd77e0b3831c1382af43502ebed5f 100644
--- a/src/libs/libs.pro
+++ b/src/libs/libs.pro
@@ -16,6 +16,12 @@ SUBDIRS   = \
     qtcomponents/styleitem \
     ssh \
     zeroconf
+
+exists(../shared/qbs/qbs.pro):SUBDIRS += \
+    ../shared/qbs/src/lib \
+    ../shared/qbs/src/plugins \
+    ../shared/qbs/static.pro
+
 win32:SUBDIRS += utils/process_ctrlc_stub.pro
 
 # Windows: Compile Qt Creator CDB extension if Debugging tools can be detected.    
diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp
index 64ba72802591b8e17d327b22e4760edb425a70f9..e1164e93bfebaeade5f259bc74d28ea8ac158666 100644
--- a/src/plugins/android/androidconfigurations.cpp
+++ b/src/plugins/android/androidconfigurations.cpp
@@ -591,11 +591,6 @@ void AndroidConfigurations::updateAutomaticKitList()
             continue;
         if (k->isSdkProvided())
             continue;
-        ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain((k));
-        if (!tc)
-            continue;
-        if (tc->type() != QLatin1String(Constants::ANDROID_TOOLCHAIN_TYPE))
-            continue;
 
         existingKits << k;
     }
diff --git a/src/plugins/android/androidplugin.cpp b/src/plugins/android/androidplugin.cpp
index b1a67572ab34aaa4bcca9db2a39c315d43156131..8592bc1618f75d5f52d0e84721ba50d88bb09ff8 100644
--- a/src/plugins/android/androidplugin.cpp
+++ b/src/plugins/android/androidplugin.cpp
@@ -74,16 +74,14 @@ bool AndroidPlugin::initialize(const QStringList &arguments, QString *errorMessa
     addAutoReleasedObject(new Internal::AndroidDeployConfigurationFactory);
     addAutoReleasedObject(new Internal::AndroidDeviceFactory);
     ProjectExplorer::KitManager::instance()->registerKitInformation(new Internal::AndroidGdbServerKitInformation);
-    return true;
-}
 
-void AndroidPlugin::extensionsInitialized()
-{
-    ProjectExplorer::DeviceManager *dm = ProjectExplorer::DeviceManager::instance();
-    if (dm->find(Core::Id(Constants::ANDROID_DEVICE_ID)).isNull())
-        dm->addDevice(ProjectExplorer::IDevice::Ptr(new Internal::AndroidDevice));
-    connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsChanged()),
+    ProjectExplorer::DeviceManager::instance()
+            ->addDevice(ProjectExplorer::IDevice::Ptr(new Internal::AndroidDevice));
+
+    connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsLoaded()),
             this, SLOT(kitsRestored()));
+
+    return true;
 }
 
 void AndroidPlugin::kitsRestored()
diff --git a/src/plugins/android/androidplugin.h b/src/plugins/android/androidplugin.h
index 168ac611dd0c362aa818deac6d6fd3991035fef7..c26cc5d0f05579a9173c13e6ff7d3bbeefeb3468 100644
--- a/src/plugins/android/androidplugin.h
+++ b/src/plugins/android/androidplugin.h
@@ -43,7 +43,8 @@ public:
     AndroidPlugin();
 
     bool initialize(const QStringList &arguments, QString *errorMessage);
-    void extensionsInitialized();
+    void extensionsInitialized() { }
+
 private slots:
     void kitsRestored();
 };
diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp
index bd144aa40703f5860bb3a2d202b35503e301b53b..6eb5b9663224257bbe75cd0f48d24675637fe80e 100644
--- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp
@@ -35,6 +35,7 @@
 #include <utils/hostosinfo.h>
 #include <utils/pathchooser.h>
 #include <utils/fancylineedit.h>
+#include <utils/historycompleter.h>
 #include <projectexplorer/kitinformation.h>
 #include <projectexplorer/kitmanager.h>
 #include <projectexplorer/toolchain.h>
@@ -74,7 +75,7 @@ namespace Internal {
         Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::GeneratorInfo)
     public:
         enum Ninja { NoNinja, OfferNinja, ForceNinja };
-        static QList<GeneratorInfo> generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool hasCodeBlocks);
+        static QList<GeneratorInfo> generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool preferNinja, bool hasCodeBlocks);
 
         GeneratorInfo();
         explicit GeneratorInfo(ProjectExplorer::Kit *kit, bool ninja = false);
@@ -171,7 +172,7 @@ QString GeneratorInfo::displayName() const
     return QString();
 }
 
-QList<GeneratorInfo> GeneratorInfo::generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool hasCodeBlocks)
+QList<GeneratorInfo> GeneratorInfo::generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool preferNinja, bool hasCodeBlocks)
 {
     QList<GeneratorInfo> results;
     ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
@@ -194,8 +195,12 @@ QList<GeneratorInfo> GeneratorInfo::generatorInfosFor(ProjectExplorer::Kit *k, N
             results << GeneratorInfo(k);
         }
     }
-    if (n != NoNinja)
-        results << GeneratorInfo(k, true);
+    if (n != NoNinja) {
+        if (preferNinja)
+            results.prepend(GeneratorInfo(k, true));
+        else
+            results.append(GeneratorInfo(k, true));
+    }
     return results;
 }
 
@@ -281,6 +286,7 @@ bool CMakeOpenProjectWizard::compatibleKitExist() const
 {
     bool hasCodeBlocksGenerator = m_cmakeManager->hasCodeBlocksMsvcGenerator();
     bool hasNinjaGenerator = m_cmakeManager->hasCodeBlocksNinjaGenerator();
+    bool preferNinja = m_cmakeManager->preferNinja();
 
     QList<ProjectExplorer::Kit *> kitList =
             ProjectExplorer::KitManager::instance()->kits();
@@ -291,6 +297,7 @@ bool CMakeOpenProjectWizard::compatibleKitExist() const
         // are interested in here
         QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(k,
                                                                       hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja,
+                                                                      preferNinja,
                                                                       hasCodeBlocksGenerator);
         if (!infos.isEmpty())
             return true;
@@ -647,6 +654,7 @@ void CMakeRunPage::initializePage()
 
     bool hasCodeBlocksGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksMsvcGenerator();
     bool hasNinjaGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksNinjaGenerator();
+    bool preferNinja = m_cmakeWizard->cmakeManager()->preferNinja();
 
     if (m_mode == Initial) {
         // Try figuring out generator and toolchain from CMakeCache.txt
@@ -655,16 +663,23 @@ void CMakeRunPage::initializePage()
         m_generatorComboBox->show();
         QList<ProjectExplorer::Kit *> kitList =
                 ProjectExplorer::KitManager::instance()->kits();
+        int defaultIndex = 0;
 
         foreach (ProjectExplorer::Kit *k, kitList) {
             QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(k,
                                                                           hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja,
+                                                                          preferNinja,
                                                                           hasCodeBlocksGenerator);
 
+            if (k == ProjectExplorer::KitManager::instance()->defaultKit())
+                defaultIndex = m_generatorComboBox->count();
+
             foreach (const GeneratorInfo &info, infos)
                 if (cachedGenerator.isEmpty() || info.generator() == cachedGenerator)
                     m_generatorComboBox->addItem(info.displayName(), qVariantFromValue(info));
         }
+
+        m_generatorComboBox->setCurrentIndex(defaultIndex);
     } else {
         // Note: We don't compare the actually cached generator to what is set in the buildconfiguration
         // We assume that the buildconfiguration is correct
@@ -680,6 +695,7 @@ void CMakeRunPage::initializePage()
 
         QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(m_cmakeWizard->kit(),
                                                                       ninja,
+                                                                      preferNinja,
                                                                       true);
         foreach (const GeneratorInfo &info, infos)
             m_generatorComboBox->addItem(info.displayName(), qVariantFromValue(info));
@@ -781,6 +797,7 @@ void CMakeRunPage::cmakeFinished()
     if (m_cmakeProcess->exitCode() != 0) {
         m_exitCodeLabel->setVisible(true);
         m_exitCodeLabel->setText(tr("CMake exited with errors. Please check CMake output."));
+        static_cast<Utils::HistoryCompleter *>(m_argumentsLineEdit->completer())->removeHistoryItem(0);
         m_haveCbpFile = false;
     } else {
         m_exitCodeLabel->setVisible(false);
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
index 726905c162386a45d8e9c570a5e73fce1ee66b4d..0d82f11098747d309f80c2e2fe27a860f42db003 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
@@ -161,6 +161,11 @@ bool CMakeManager::hasCodeBlocksNinjaGenerator() const
     return m_settingsPage->hasCodeBlocksNinjaGenerator();
 }
 
+bool CMakeManager::preferNinja() const
+{
+    return m_settingsPage->preferNinja();
+}
+
 // need to refactor this out
 // we probably want the process instead of this function
 // cmakeproject then could even run the cmake process in the background, adding the files afterwards
@@ -241,7 +246,7 @@ QString CMakeManager::qtVersionForQMake(const QString &qmakePath)
 
 
 CMakeSettingsPage::CMakeSettingsPage()
-    :  m_pathchooser(0)
+    :  m_pathchooser(0), m_preferNinja(0)
 {
     setId("Z.CMake");
     setDisplayName(tr("CMake"));
@@ -288,6 +293,11 @@ QWidget *CMakeSettingsPage::createPage(QWidget *parent)
     formLayout->addRow(tr("Executable:"), m_pathchooser);
     formLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
     m_pathchooser->setPath(m_cmakeValidatorForUser.cmakeExecutable());
+
+    m_preferNinja = new QCheckBox(tr("Prefer Ninja generator (CMake 2.8.9 or higher required)"));
+    m_preferNinja->setChecked(preferNinja());
+    formLayout->addRow(m_preferNinja);
+
     return outerWidget;
 }
 
@@ -296,6 +306,7 @@ void CMakeSettingsPage::saveSettings() const
     QSettings *settings = Core::ICore::settings();
     settings->beginGroup(QLatin1String("CMakeSettings"));
     settings->setValue(QLatin1String("cmakeExecutable"), m_cmakeValidatorForUser.cmakeExecutable());
+    settings->setValue(QLatin1String("preferNinja"), m_preferNinja->isChecked());
     settings->endGroup();
 }
 
@@ -303,9 +314,8 @@ void CMakeSettingsPage::apply()
 {
     if (!m_pathchooser) // page was never shown
         return;
-    if (m_cmakeValidatorForUser.cmakeExecutable() == m_pathchooser->path())
-        return;
-    m_cmakeValidatorForUser.setCMakeExecutable(m_pathchooser->path());
+    if (m_cmakeValidatorForUser.cmakeExecutable() != m_pathchooser->path())
+        m_cmakeValidatorForUser.setCMakeExecutable(m_pathchooser->path());
     saveSettings();
 }
 
@@ -351,6 +361,15 @@ bool CMakeSettingsPage::hasCodeBlocksNinjaGenerator() const
     return false;
 }
 
+bool CMakeSettingsPage::preferNinja() const
+{
+    QSettings *settings = Core::ICore::settings();
+    settings->beginGroup(QLatin1String("CMakeSettings"));
+    const bool r = settings->value(QLatin1String("preferNinja"), false).toBool();
+    settings->endGroup();
+    return r;
+}
+
 TextEditor::Keywords CMakeSettingsPage::keywords()
 {
     if (m_cmakeValidatorForUser.isValid())
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
index b67c6654bdb502c774e1eb601bcdbd06a8fd9599..55e45071476c1e0eee1ee164b55cddd4244e0a1b 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
@@ -42,6 +42,7 @@
 
 #include <QFuture>
 #include <QStringList>
+#include <QCheckBox>
 #include <QDir>
 #include <QVector>
 #include <QAction>
@@ -81,6 +82,7 @@ public:
                        const QString &generator);
     bool hasCodeBlocksMsvcGenerator() const;
     bool hasCodeBlocksNinjaGenerator() const;
+    bool preferNinja() const;
     static QString findCbpFile(const QDir &);
 
     static QString findDumperLibrary(const Utils::Environment &env);
@@ -115,6 +117,7 @@ public:
     bool isCMakeExecutableValid() const;
     bool hasCodeBlocksMsvcGenerator() const;
     bool hasCodeBlocksNinjaGenerator() const;
+    bool preferNinja() const;
 
     TextEditor::Keywords keywords();
 
@@ -123,6 +126,7 @@ private:
     QString findCmakeExecutable() const;
 
     Utils::PathChooser *m_pathchooser;
+    QCheckBox *m_preferNinja;
     CMakeValidator m_cmakeValidatorForUser;
     CMakeValidator m_cmakeValidatorForSystem;
 };
diff --git a/src/plugins/cmakeprojectmanager/cmakevalidator.cpp b/src/plugins/cmakeprojectmanager/cmakevalidator.cpp
index d6d971d70c4e9d0afeeec8c804c0384bfb2e2daf..27d38291cb22ba419c869c97c8bf55f52cf4a609 100644
--- a/src/plugins/cmakeprojectmanager/cmakevalidator.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakevalidator.cpp
@@ -89,7 +89,6 @@ void CMakeValidator::finished(int exitCode)
         QRegExp versionRegexp(QLatin1String("^cmake version ([\\d\\.]*)"));
         versionRegexp.indexIn(QString::fromLocal8Bit(response));
 
-        //m_supportsQtCreator = response.contains(QLatin1String("QtCreator"));
         m_hasCodeBlocksMsvcGenerator = response.contains("CodeBlocks - NMake Makefiles");
         m_hasCodeBlocksNinjaGenerator = response.contains("CodeBlocks - Ninja");
         m_version = versionRegexp.cap(1);
@@ -101,16 +100,27 @@ void CMakeValidator::finished(int exitCode)
         } else {
             m_state = CMakeValidator::RunningFunctionList;
             if (!startProcess(QStringList(QLatin1String("--help-command-list"))))
-                finished(0); // shoud never happen, just continue
+                finished(0); // should never happen, just continue
         }
     } else if (m_state == CMakeValidator::RunningFunctionList) {
         parseFunctionOutput(m_process->readAll());
         m_state = CMakeValidator::RunningFunctionDetails;
         if (!startProcess(QStringList(QLatin1String("--help-commands"))))
-            finished(0); // shoud never happen, just continue
+            finished(0); // should never happen, just continue
     } else if (m_state == CMakeValidator::RunningFunctionDetails) {
         parseFunctionDetailsOutput(m_process->readAll());
-        m_state = CMakeValidator::ValidFunctionDetails;
+        m_state = CMakeValidator::RunningPropertyList;
+        if (!startProcess(QStringList(QLatin1String("--help-property-list"))))
+            finished(0); // should never happen, just continue
+    } else if (m_state == CMakeValidator::RunningPropertyList) {
+        parseVariableOutput(m_process->readAll());
+        m_state = CMakeValidator::RunningVariableList;
+        if (!startProcess(QStringList(QLatin1String("--help-variable-list"))))
+            finished(0); // should never happen, just continue
+    } else if (m_state == CMakeValidator::RunningVariableList) {
+        parseVariableOutput(m_process->readAll());
+        parseDone();
+        m_state = CMakeValidator::RunningDone;
     }
 }
 
@@ -148,10 +158,9 @@ bool CMakeValidator::hasCodeBlocksNinjaGenerator() const
     return m_hasCodeBlocksNinjaGenerator;
 }
 
-
 TextEditor::Keywords CMakeValidator::keywords()
 {
-    while (m_state != ValidFunctionDetails && m_state != CMakeValidator::Invalid) {
+    while (m_state != RunningDone && m_state != CMakeValidator::Invalid) {
         m_process->waitForFinished();
     }
 
@@ -253,6 +262,31 @@ void CMakeValidator::parseFunctionDetailsOutput(const QByteArray &output)
         }
     }
     m_functions = m_functionArgs.keys();
+}
+
+void CMakeValidator::parseVariableOutput(const QByteArray &output)
+{
+    QList<QByteArray> variableList = output.split('\n');
+    if (!variableList.isEmpty()) {
+        variableList.removeFirst(); //remove version string
+        foreach (const QByteArray &variable, variableList) {
+            if (variable.contains("_<CONFIG>")) {
+                m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_<CONFIG>"), QLatin1String("_DEBUG"));
+                m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_<CONFIG>"), QLatin1String("_RELEASE"));
+                m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_<CONFIG>"), QLatin1String("_MINSIZEREL"));
+                m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_<CONFIG>"), QLatin1String("_RELWITHDEBINFO"));
+            } else if (variable.contains("_<LANG>")) {
+                m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_<LANG>"), QLatin1String("_C"));
+                m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_<LANG>"), QLatin1String("_CXX"));
+            } else if (!variable.contains("_<") && !variable.contains('[')) {
+                m_variables << QString::fromLocal8Bit(variable);
+            }
+        }
+    }
+}
+
+void CMakeValidator::parseDone()
+{
     m_variables.sort();
     m_variables.removeDuplicates();
 }
diff --git a/src/plugins/cmakeprojectmanager/cmakevalidator.h b/src/plugins/cmakeprojectmanager/cmakevalidator.h
index 01c4f274fe0b67247b9d35440fc98e4f89b34210..945a2271ff799d6bdce990e7177961ec350fc37a 100644
--- a/src/plugins/cmakeprojectmanager/cmakevalidator.h
+++ b/src/plugins/cmakeprojectmanager/cmakevalidator.h
@@ -47,7 +47,8 @@ public:
     CMakeValidator();
     ~CMakeValidator();
 
-    enum State { Invalid, RunningBasic, RunningFunctionList, RunningFunctionDetails, ValidFunctionDetails };
+    enum State { Invalid, RunningBasic, RunningFunctionList, RunningFunctionDetails,
+                 RunningPropertyList, RunningVariableList, RunningDone };
     void cancel();
     bool isValid() const;
 
@@ -65,6 +66,8 @@ private:
     bool startProcess(const QStringList &args);
     void parseFunctionOutput(const QByteArray &output);
     void parseFunctionDetailsOutput(const QByteArray &output);
+    void parseVariableOutput(const QByteArray &output);
+    void parseDone();
     QString formatFunctionDetails(const QString &command, const QString &args);
 
     State m_state;
diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp
index f5ea9aeb707b424eaa9c5e52d35b4846d00340f8..25ebd22851331c3d55fe208b840ce9384b469be1 100644
--- a/src/plugins/coreplugin/coreplugin.cpp
+++ b/src/plugins/coreplugin/coreplugin.cpp
@@ -44,6 +44,7 @@
 
 #include <QtPlugin>
 #include <QDebug>
+#include <QDateTime>
 
 using namespace Core;
 using namespace Core::Internal;
@@ -87,6 +88,7 @@ void CorePlugin::parseArguments(const QStringList &arguments)
 
 bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
 {
+    qsrand(QDateTime::currentDateTime().toTime_t());
     parseArguments(arguments);
     const bool success = m_mainWindow->init(errorMessage);
     if (success) {
diff --git a/src/plugins/coreplugin/externaltool.cpp b/src/plugins/coreplugin/externaltool.cpp
index 188b4b895ef1e3ad36149e3f7f8729f1450ea0c5..1d3a5bdc969e0278dc2f63de6f887361df72caed 100644
--- a/src/plugins/coreplugin/externaltool.cpp
+++ b/src/plugins/coreplugin/externaltool.cpp
@@ -319,7 +319,7 @@ static void localizedText(const QStringList &locales, QXmlStreamReader *reader,
     } else {
         if (*currentLocale < 0 && currentText->isEmpty()) {
             *currentText = QCoreApplication::translate("Core::Internal::ExternalTool",
-                                                       reader->readElementText().toLatin1().constData());
+                                                       reader->readElementText().toUtf8().constData());
         } else {
             reader->skipCurrentElement();
         }
diff --git a/src/plugins/coreplugin/toolsettings.cpp b/src/plugins/coreplugin/toolsettings.cpp
index d76af89a1a532346d8cb89d4eda3e8611ba2da9c..0b0a66a88979316ff1ace2d5cc14c08780a0d11e 100644
--- a/src/plugins/coreplugin/toolsettings.cpp
+++ b/src/plugins/coreplugin/toolsettings.cpp
@@ -75,7 +75,6 @@ QWidget *ToolSettings::createPage(QWidget *parent)
 
 static QString getUserFilePath(const QString &proposalFileName)
 {
-    static bool seeded = false;
     QDir resourceDir(ICore::userResourcePath());
     if (!resourceDir.exists(QLatin1String("externaltools")))
         resourceDir.mkpath(QLatin1String("externaltools"));
@@ -89,10 +88,6 @@ static QString getUserFilePath(const QString &proposalFileName)
         if (count > 15)
             return QString();
         // add random number
-        if (!seeded) {
-            seeded = true;
-            qsrand(QTime::currentTime().msec());
-        }
         int number = qrand() % 1000;
         tryPath = newFilePath + QString::number(number) + suffix;
     }
diff --git a/src/plugins/cppeditor/cppinsertdecldef.cpp b/src/plugins/cppeditor/cppinsertdecldef.cpp
index 270310a44fd6b65aae4c4c4287b33dba7a619f9c..51d4558fb9368d983421b758f5016e9effad12a6 100644
--- a/src/plugins/cppeditor/cppinsertdecldef.cpp
+++ b/src/plugins/cppeditor/cppinsertdecldef.cpp
@@ -298,9 +298,7 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
             if (simpleDecl->symbols && ! simpleDecl->symbols->next) {
                 if (Symbol *symbol = simpleDecl->symbols->value) {
                     if (Declaration *decl = symbol->asDeclaration()) {
-                        if (decl->type()->isFunctionType()
-                                && decl->enclosingScope()
-                                && decl->enclosingScope()->isClass()) {
+                        if (decl->type()->isFunctionType()) {
                             CppRefactoringChanges refactoring(interface->snapshot());
                             InsertionPointLocator locator(refactoring);
                             foreach (const InsertionLocation &loc, locator.methodDefinition(decl)) {
diff --git a/src/plugins/cppeditor/cppplugin.h b/src/plugins/cppeditor/cppplugin.h
index 7c7a7a755886ebf361013be00ba8773ef3c6a964..d7db3038d9e0a3492e3282bf1da9f12d233f2811 100644
--- a/src/plugins/cppeditor/cppplugin.h
+++ b/src/plugins/cppeditor/cppplugin.h
@@ -113,7 +113,15 @@ private slots:
     void test_quickfix_GenerateGetterSetter_notTriggeringOnMemberFunction();
     void test_quickfix_GenerateGetterSetter_notTriggeringOnMemberArray();
     void test_quickfix_GenerateGetterSetter_notTriggeringWhenGetterOrSetterExist();
+
     void test_quickfix_ReformatPointerDeclaration();
+
+    void test_quickfix_InsertDefFromDecl_basic();
+    void test_quickfix_InsertDefFromDecl_headerSource_basic1();
+    void test_quickfix_InsertDefFromDecl_headerSource_basic2();
+    void test_quickfix_InsertDefFromDecl_headerSource_namespace1();
+    void test_quickfix_InsertDefFromDecl_headerSource_namespace2();
+    void test_quickfix_InsertDefFromDecl_freeFunction();
 #endif // WITH_TESTS
 
 private:
diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp
index 3899b469b952925ac4bcd44474201cf225aadd1e..8c91cb5f1589daa9f150c256af6ff500b5c8f5ea 100644
--- a/src/plugins/cppeditor/cppquickfix_test.cpp
+++ b/src/plugins/cppeditor/cppquickfix_test.cpp
@@ -718,3 +718,184 @@ void CppPlugin::test_quickfix_ReformatPointerDeclaration()
     TestCase data(original, expected);
     data.run(&factory);
 }
+
+/// Check from source file: If there is no header file, insert the definition after the class.
+void CppPlugin::test_quickfix_InsertDefFromDecl_basic()
+{
+    const QByteArray original =
+        "struct Foo\n"
+        "{\n"
+        "    Foo();@\n"
+        "};\n"
+        "\n"
+        ;
+    const QByteArray expected = original +
+        "\n"
+        "Foo::Foo()\n"
+        "{\n"
+        "}\n"
+        "\n"
+        ;
+
+    InsertDefFromDecl factory;
+    TestCase data(original, expected);
+    data.run(&factory);
+}
+
+/// Check from header file: If there is a source file, insert the definition in the source file.
+void CppPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic1()
+{
+    QList<TestDocumentPtr> testFiles;
+
+    QByteArray original;
+    QByteArray expected;
+
+    // Header File
+    original =
+        "struct Foo\n"
+        "{\n"
+        "    Foo()@;\n"
+        "};\n";
+    expected = original + "\n";
+    testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+
+    // Source File
+    original.resize(0);
+    expected =
+        "\n"
+        "Foo::Foo()\n"
+        "{\n"
+        "}\n"
+        "\n"
+        ;
+    testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+
+    InsertDefFromDecl factory;
+    TestCase data(testFiles);
+    data.run(&factory);
+}
+
+/// Check from source file: Insert in source file, not header file.
+void CppPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic2()
+{
+    QList<TestDocumentPtr> testFiles;
+
+    QByteArray original;
+    QByteArray expected;
+
+    // Empty Header File
+    testFiles << TestDocument::create("", "\n", QLatin1String("file.h"));
+
+    // Source File
+    original =
+        "struct Foo\n"
+        "{\n"
+        "    Foo()@;\n"
+        "};\n";
+    expected = original +
+        "\n"
+        "\n"
+        "Foo::Foo()\n"
+        "{\n"
+        "}\n"
+        "\n"
+        ;
+    testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+
+    InsertDefFromDecl factory;
+    TestCase data(testFiles);
+    data.run(&factory);
+}
+
+/// Check from header file: If the class is in a namespace, the added function definition
+/// name must be qualified accordingly.
+void CppPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace1()
+{
+    QList<TestDocumentPtr> testFiles;
+
+    QByteArray original;
+    QByteArray expected;
+
+    // Header File
+    original =
+        "namespace N {\n"
+        "struct Foo\n"
+        "{\n"
+        "    Foo()@;\n"
+        "};\n"
+        "}\n";
+    expected = original + "\n";
+    testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+
+    // Source File
+    original.resize(0);
+    expected =
+        "\n"
+        "N::Foo::Foo()\n"
+        "{\n"
+        "}\n"
+        "\n"
+        ;
+    testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+
+    InsertDefFromDecl factory;
+    TestCase data(testFiles);
+    data.run(&factory);
+}
+
+/// Check from header file: If the class is in namespace N and the source file has a
+/// "using namespace N" line, the function definition name must be qualified accordingly.
+void CppPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace2()
+{
+    QList<TestDocumentPtr> testFiles;
+
+    QByteArray original;
+    QByteArray expected;
+
+    // Header File
+    original =
+        "namespace N {\n"
+        "struct Foo\n"
+        "{\n"
+        "    Foo()@;\n"
+        "};\n"
+        "}\n";
+    expected = original + "\n";
+    testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+
+    // Source File
+    original =
+        "#include \"file.h\"\n"
+        "using namespace N;\n"
+        "\n"
+        ;
+    expected = original +
+        "\n"
+        "Foo::Foo()\n"
+        "{\n"
+        "}\n"
+        "\n"
+        ;
+    testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+
+    InsertDefFromDecl factory;
+    TestCase data(testFiles);
+    data.run(&factory);
+}
+
+void CppPlugin::test_quickfix_InsertDefFromDecl_freeFunction()
+{
+    const QByteArray original = "void free()@;\n";
+    const QByteArray expected = original +
+        "\n"
+        "\n"
+        "void free()\n"
+        "{\n"
+        "}\n"
+        "\n"
+        ;
+
+    InsertDefFromDecl factory;
+    TestCase data(original, expected);
+    data.run(&factory);
+}
diff --git a/src/plugins/cpptools/cppchecksymbols.cpp b/src/plugins/cpptools/cppchecksymbols.cpp
index d99e49934de08d9de4d6f43309b623c5974fd0a4..fbf27666060d6042df8379da33297f319d0e491c 100644
--- a/src/plugins/cpptools/cppchecksymbols.cpp
+++ b/src/plugins/cpptools/cppchecksymbols.cpp
@@ -285,7 +285,10 @@ protected:
 
 static bool sortByLinePredicate(const CheckSymbols::Use &lhs, const CheckSymbols::Use &rhs)
 {
-    return lhs.line < rhs.line;
+    if (lhs.line == rhs.line)
+        return lhs.column < rhs.column;
+    else
+        return lhs.line < rhs.line;
 }
 
 
@@ -325,7 +328,7 @@ CheckSymbols::CheckSymbols(Document::Ptr doc, const LookupContext &context, cons
 
     unsigned line = 0;
     getTokenEndPosition(translationUnit()->ast()->lastToken(), &line, 0);
-    _chunkSize = qMin(50U, line / 200);
+    _chunkSize = qMax(50U, line / 200);
     _usages.reserve(_chunkSize);
 
     _astStack.reserve(200);
diff --git a/src/plugins/debugger/debuggerkitinformation.cpp b/src/plugins/debugger/debuggerkitinformation.cpp
index 10bc34d3ab0a59a83c58a431df6559bbf8d92325..b468fbe6f8e8c838fd1834e566428f016425fe4e 100644
--- a/src/plugins/debugger/debuggerkitinformation.cpp
+++ b/src/plugins/debugger/debuggerkitinformation.cpp
@@ -34,6 +34,7 @@
 #include <projectexplorer/abi.h>
 #include <projectexplorer/projectexplorerconstants.h>
 #include <projectexplorer/toolchain.h>
+#include <projectexplorer/toolchainmanager.h>
 
 #include <utils/environment.h>
 #include <utils/qtcassert.h>
@@ -201,6 +202,7 @@ DebuggerKitInformation::DebuggerItem DebuggerKitInformation::autoDetectItem(cons
 
 void DebuggerKitInformation::setup(Kit *k)
 {
+    QTC_ASSERT(ToolChainManager::instance()->isLoaded(), return);
     setDebuggerItem(k, autoDetectItem(k));
 }
 
diff --git a/src/plugins/debugger/lldblib/lldboptionspage.cpp b/src/plugins/debugger/lldblib/lldboptionspage.cpp
index 9fe0cb2a3061b2e44455e363c83f956903ad459a..19b4591b84ba68b47b8d5901a24ac179edeceb9f 100644
--- a/src/plugins/debugger/lldblib/lldboptionspage.cpp
+++ b/src/plugins/debugger/lldblib/lldboptionspage.cpp
@@ -70,11 +70,11 @@ void LldbOptionsPageWidget::load()
 LldbOptionsPage::LldbOptionsPage()
 {
     //    m_options->fromSettings(Core::ICore::settings());
-    setId(QLatin1String("F.Lldb"));
+    setId(Core::Id("F.Lldb"));
     setDisplayName(tr("LLDB"));
     setCategory(Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY);
     setDisplayCategory(QCoreApplication::translate("Debugger", Constants::DEBUGGER_SETTINGS_TR_CATEGORY));
-    setCategoryIcon(QIcon(QLatin1String(Constants::DEBUGGER_COMMON_SETTINGS_CATEGORY_ICON)));
+    setCategoryIcon(QLatin1String(Constants::DEBUGGER_COMMON_SETTINGS_CATEGORY_ICON));
 }
 
 QWidget *LldbOptionsPage::createPage(QWidget *parent)
@@ -96,7 +96,7 @@ void LldbOptionsPage::finish()
 
 bool LldbOptionsPage::matches(const QString &s) const
 {
-    return QString(s.toLower()).contains("lldb");
+    return QString(s.toLower()).contains(QLatin1String("lldb"));
 }
 
 void addLldbOptionPages(QList<Core::IOptionsPage *> *opts)
diff --git a/src/plugins/genericprojectmanager/genericprojectnodes.cpp b/src/plugins/genericprojectmanager/genericprojectnodes.cpp
index 4540bdaaccb79c37c984f4684ebd3786e629423e..16db06a1dca98cfeb7d700b786da5c1221e479f0 100644
--- a/src/plugins/genericprojectmanager/genericprojectnodes.cpp
+++ b/src/plugins/genericprojectmanager/genericprojectnodes.cpp
@@ -71,6 +71,8 @@ QHash<QString, QStringList> sortFilesIntoPaths(const QString &base, const QSet<Q
         } else {
             // `file' is not part of the project.
             relativeFilePath = baseDir.relativeFilePath(absoluteFilePath.toString());
+            if (relativeFilePath.endsWith(QLatin1Char('/')))
+                relativeFilePath.chop(1);
         }
 
         filesInPath[relativeFilePath].append(absoluteFileName);
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 5a4b1ee93d2f29dca6d52f9ab1ea8042f2fc99e4..4eb76445e6c1baa8a0799af802aa8027f782cecd 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -365,6 +365,8 @@ const char *GitClient::decorateOption = "--decorate";
 
 QString GitClient::findRepositoryForDirectory(const QString &dir)
 {
+    if (dir.endsWith(QLatin1String("/.git")) || dir.contains(QLatin1String("/.git/")))
+        return QString();
     // Find a directory to run git in:
     const QString root = QDir::rootPath();
     const QString home = QDir::homePath();
@@ -1459,8 +1461,7 @@ VcsBase::Command *GitClient::createCommand(const QString &workingDirectory,
             connect(command, SIGNAL(outputData(QByteArray)), editor, SLOT(setPlainTextDataFiltered(QByteArray)));
     }
 
-    if (outputWindow())
-        connect(command, SIGNAL(errorText(QString)), outputWindow(), SLOT(appendError(QString)));
+    connect(command, SIGNAL(errorText(QString)), outputWindow(), SLOT(appendError(QString)));
     return command;
 }
 
@@ -1822,7 +1823,7 @@ bool GitClient::getCommitData(const QString &workingDirectory,
 
     commitData->panelInfo.repository = repoDirectory;
 
-    QString gitDir = GitClient::findGitDirForRepository(repoDirectory);
+    QString gitDir = findGitDirForRepository(repoDirectory);
     if (gitDir.isEmpty()) {
         *errorMessage = tr("The repository \"%1\" is not initialized.").arg(repoDirectory);
         return false;
@@ -2151,7 +2152,7 @@ bool GitClient::executeAndHandleConflicts(const QString &workingDirectory,
         handleMergeConflicts(workingDirectory, conflictedCommit.cap(1), abortCommand);
     } else if (resp.stdErr.contains(QLatin1String("conflict"))) {
         // cherry-pick/revert conflict is output to stdErr
-        QRegExp conflictedCommit(QLatin1String("could not (?:apply|revert) ([^\\n]*)$"));
+        QRegExp conflictedCommit(QLatin1String("could not (?:apply|revert) ([^\\n]*)"));
         conflictedCommit.indexIn(resp.stdErr);
         handleMergeConflicts(workingDirectory, conflictedCommit.cap(1), abortCommand);
     }
@@ -2444,9 +2445,11 @@ QString GitClient::readConfig(const QString &workingDirectory, const QStringList
 
     QByteArray outputText;
     QByteArray errorText;
-    if (fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText, false))
-        return commandOutputFromLocal8Bit(outputText);
-    return QString();
+    if (!fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText, false))
+        return QString();
+    if (Utils::HostOsInfo::isWindowsHost())
+        return QString::fromUtf8(outputText).remove(QLatin1Char('\r'));
+    return commandOutputFromLocal8Bit(outputText);
 }
 
 // Read a single-line config value, return trimmed
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index 00a3f76e993c1e9b8e6d4234dd925acabcbaf316..1c8c4b1d3aa515c9a212114dc9f9b7af30dc4b7c 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -918,11 +918,15 @@ bool GitPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEdi
     // Prompt user. Force a prompt unless submit was actually invoked (that
     // is, the editor was closed or shutdown).
     bool *promptData = m_settings.boolPointer(GitSettings::promptOnSubmitKey);
-    const VcsBase::VcsBaseSubmitEditor::PromptSubmitResult answer =
-            editor->promptSubmit(tr("Closing Git Editor"),
-                                 tr("Do you want to commit the change?"),
-                                 tr("Git will not accept this commit. Do you want to continue to edit it?"),
-                                 promptData, !m_submitActionTriggered, false);
+    VcsBase::VcsBaseSubmitEditor::PromptSubmitResult answer;
+    if (editor->forceClose()) {
+        answer = VcsBase::VcsBaseSubmitEditor::SubmitDiscarded;
+    } else {
+        answer = editor->promptSubmit(tr("Closing Git Editor"),
+                     tr("Do you want to commit the change?"),
+                     tr("Git will not accept this commit. Do you want to continue to edit it?"),
+                     promptData, !m_submitActionTriggered, false);
+    }
     m_submitActionTriggered = false;
     switch (answer) {
     case VcsBase::VcsBaseSubmitEditor::SubmitCanceled:
diff --git a/src/plugins/git/gitsubmiteditor.cpp b/src/plugins/git/gitsubmiteditor.cpp
index 2dcb39a427e5f8fa10475f9bfbca828ccc29d080..1df68b36189e009048ee1355618c4b4a3f50ff3c 100644
--- a/src/plugins/git/gitsubmiteditor.cpp
+++ b/src/plugins/git/gitsubmiteditor.cpp
@@ -34,6 +34,7 @@
 #include "gitsubmiteditor.h"
 #include "gitsubmiteditorwidget.h"
 
+#include <coreplugin/editormanager/editormanager.h>
 #include <utils/qtcassert.h>
 #include <vcsbase/submitfilemodel.h>
 #include <vcsbase/vcsbaseoutputwindow.h>
@@ -85,7 +86,8 @@ private:
 GitSubmitEditor::GitSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters, QWidget *parent) :
     VcsBaseSubmitEditor(parameters, new GitSubmitEditorWidget(parent)),
     m_model(0),
-    m_amend(false)
+    m_amend(false),
+    m_forceClose(false)
 {
     connect(this, SIGNAL(diffSelectedFiles(QList<int>)), this, SLOT(slotDiffSelected(QList<int>)));
 }
@@ -162,10 +164,13 @@ void GitSubmitEditor::updateFileModel()
     GitClient *client = GitPlugin::instance()->gitClient();
     QString errorMessage, commitTemplate;
     CommitData data;
-    if (client->getCommitData(m_workingDirectory, m_amend, &commitTemplate, &data, &errorMessage))
+    if (client->getCommitData(m_workingDirectory, m_amend, &commitTemplate, &data, &errorMessage)) {
         setCommitData(data);
-    else
+    } else {
         VcsBase::VcsBaseOutputWindow::instance()->append(errorMessage);
+        m_forceClose = true;
+        Core::EditorManager::instance()->closeEditors(QList<IEditor*>() << this);
+    }
 }
 
 GitSubmitEditorPanelData GitSubmitEditor::panelData() const
diff --git a/src/plugins/git/gitsubmiteditor.h b/src/plugins/git/gitsubmiteditor.h
index 7a581d1a2fdb53599076c1010e76dcbc8226730c..4f88553494985f19c22e13a1f42640b50775235e 100644
--- a/src/plugins/git/gitsubmiteditor.h
+++ b/src/plugins/git/gitsubmiteditor.h
@@ -54,6 +54,7 @@ public:
     void setCommitData(const CommitData &);
     void setAmend(bool amend);
     GitSubmitEditorPanelData panelData() const;
+    bool forceClose() const { return m_forceClose; }
 
 signals:
     void diff(const QStringList &unstagedFiles, const QStringList &stagedFiles);
@@ -72,6 +73,7 @@ private:
     VcsBase::SubmitFileModel *m_model;
     QString m_commitEncoding;
     bool m_amend;
+    bool m_forceClose;
     QString m_workingDirectory;
 };
 
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 6f615111c055fa37411663de855ae605dad5350a..49b816b8f494e74c071fe4f380dd7b9a36c408c7 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -49,13 +49,7 @@ SUBDIRS   = plugin_coreplugin \
             plugin_todo \
             plugin_qnx
 
-# Look for qbs in the environment...
-isEmpty(QBS_SOURCE_DIR): QBS_SOURCE_DIR = $$(QBS_SOURCE_DIR)
-isEmpty(QBS_BUILD_DIR): QBS_BUILD_DIR = $$(QBS_BUILD_DIR)
-
-!isEmpty(QBS_SOURCE_DIR):!isEmpty(QBS_BUILD_DIR) {
-    SUBDIRS += plugin_qbsprojectmanager
-}
+exists(../shared/qbs/qbs.pro):SUBDIRS += plugin_qbsprojectmanager
 
 isEmpty(IDE_PACKAGE_MODE) {
     SUBDIRS += plugin_helloworld \
diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp
index 656e0b05a50e8ef72474cd049be1648eca3c50e2..2bce7938efbcf47a9d5223b8657ff8c628d407b0 100644
--- a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp
+++ b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp
@@ -33,6 +33,7 @@
 #include <coreplugin/icore.h>
 #include <coreplugin/id.h>
 #include <extensionsystem/pluginmanager.h>
+#include <projectexplorer/project.h>
 #include <utils/persistentsettings.h>
 #include <utils/qtcassert.h>
 
@@ -49,16 +50,6 @@
 namespace ProjectExplorer {
 namespace Internal {
 
-static IDevice::Ptr findAutoDetectedDevice(const QList<IDevice::Ptr> &deviceList,
-        Core::Id type, const Core::Id id)
-{
-    foreach (const IDevice::Ptr &device, deviceList) {
-        if (device->isAutoDetected() && device->type() == type && device->id() == id)
-            return device;
-    }
-    return IDevice::Ptr();
-}
-
 const char DeviceManagerKey[] = "DeviceManager";
 const char DeviceListKey[] = "DeviceList";
 const char DefaultDevicesKey[] = "DefaultDevices";
@@ -66,6 +57,9 @@ const char DefaultDevicesKey[] = "DefaultDevices";
 class DeviceManagerPrivate
 {
 public:
+    DeviceManagerPrivate() : writer(0)
+    { }
+
     int indexForId(Core::Id id) const
     {
         for (int i = 0; i < devices.count(); ++i) {
@@ -75,14 +69,15 @@ public:
         return -1;
     }
 
+    static DeviceManager *instance;
     static DeviceManager *clonedInstance;
     QList<IDevice::Ptr> devices;
-    QList<IDevice::Ptr> inactiveAutoDetectedDevices;
     QHash<Core::Id, Core::Id> defaultDevices;
 
     Utils::PersistentSettingsWriter *writer;
 };
 DeviceManager *DeviceManagerPrivate::clonedInstance = 0;
+DeviceManager *DeviceManagerPrivate::instance = 0;
 
 } // namespace Internal
 
@@ -91,8 +86,7 @@ using namespace Internal;
 
 DeviceManager *DeviceManager::instance()
 {
-    static DeviceManager deviceManager(true);
-    return &deviceManager;
+    return DeviceManagerPrivate::instance;
 }
 
 int DeviceManager::deviceCount() const
@@ -117,7 +111,7 @@ DeviceManager *DeviceManager::cloneInstance()
 {
     QTC_ASSERT(!DeviceManagerPrivate::clonedInstance, return 0);
 
-    DeviceManagerPrivate::clonedInstance = new DeviceManager;
+    DeviceManagerPrivate::clonedInstance = new DeviceManager(false);
     copy(instance(), DeviceManagerPrivate::clonedInstance, true);
     return DeviceManagerPrivate::clonedInstance;
 }
@@ -135,7 +129,7 @@ void DeviceManager::copy(const DeviceManager *source, DeviceManager *target, boo
 
 void DeviceManager::save()
 {
-    if (d->clonedInstance == this)
+    if (d->clonedInstance == this || !d->writer)
         return;
     QVariantMap data;
     data.insert(QLatin1String(DeviceManagerKey), toMap());
@@ -144,6 +138,13 @@ void DeviceManager::save()
 
 void DeviceManager::load()
 {
+    QTC_ASSERT(!d->writer, return);
+
+    // Only create writer now: We do not want to save before the settings were read!
+    d->writer = new Utils::PersistentSettingsWriter(
+                settingsFilePath(QLatin1String("/qtcreator/devices.xml")),
+                QLatin1String("QtCreatorDevices"));
+
     Utils::PersistentSettingsReader reader;
     // read devices file from global settings path
     QList<IDevice::Ptr> sdkDevices;
@@ -170,6 +171,8 @@ void DeviceManager::load()
     d->devices << sdkDevices;
 
     ensureOneDefaultDevicePerType();
+
+    emit devicesLoaded();
 }
 
 QList<IDevice::Ptr> DeviceManager::fromMap(const QVariantMap &map)
@@ -188,10 +191,7 @@ QList<IDevice::Ptr> DeviceManager::fromMap(const QVariantMap &map)
             continue;
         const IDevice::Ptr device = factory->restore(map);
         QTC_ASSERT(device, continue);
-        if (device->isAutoDetected())
-            d->inactiveAutoDetectedDevices << device;
-        else
-            devices << device;
+        addDevice(device);
     }
     return devices;
 }
@@ -209,8 +209,6 @@ QVariantMap DeviceManager::toMap() const
     QVariantList deviceList;
     foreach (const IDevice::ConstPtr &device, d->devices)
         deviceList << device->toMap();
-    foreach (const IDevice::ConstPtr &device, d->inactiveAutoDetectedDevices)
-        deviceList << device->toMap();
     map.insert(QLatin1String(DeviceListKey), deviceList);
     return map;
 }
@@ -227,46 +225,30 @@ Utils::FileName DeviceManager::systemSettingsFilePath(const QString &deviceFileR
               + deviceFileRelativePath);
 }
 
-void DeviceManager::addDevice(const IDevice::Ptr &_device)
+void DeviceManager::addDevice(const IDevice::ConstPtr &_device)
 {
     const IDevice::Ptr device = _device->clone();
 
-    QString name = device->displayName();
-    const int pos = d->indexForId(device->id());
-    if (pos >= 0) {
-        device->setDisplayName(QString()); // For name uniquification to work.
-        d->devices[pos] = device;
+    QStringList names;
+    foreach (const IDevice::ConstPtr &tmp, d->devices) {
+        if (tmp->id() != device->id())
+            names << tmp->displayName();
     }
 
-    // Ensure uniqueness of name.
-    if (hasDevice(name)) {
-        const QString nameTemplate = name + QLatin1String(" (%1)");
-        int suffix = 2;
-        do
-            name = nameTemplate.arg(QString::number(suffix++));
-        while (hasDevice(name));
-    }
-    device->setDisplayName(name);
+    device->setDisplayName(Project::makeUnique(device->displayName(), names));
+
+    const int pos = d->indexForId(device->id());
 
     if (!defaultDevice(device->type()))
         d->defaultDevices.insert(device->type(), device->id());
-    if (this == instance() && d->clonedInstance)
+    if (this == DeviceManagerPrivate::instance && d->clonedInstance)
         d->clonedInstance->addDevice(device->clone());
 
     if (pos >= 0) {
+        d->devices[pos] = device;
         emit deviceUpdated(device->id());
     } else {
         d->devices << device;
-        if (this == instance()) {
-            QList<IDevice::Ptr>::Iterator it = d->inactiveAutoDetectedDevices.begin();
-            while (it != d->inactiveAutoDetectedDevices.end()) {
-                if (it->data()->id() == device->id()) {
-                    d->inactiveAutoDetectedDevices.erase(it);
-                    break;
-                }
-                ++it;
-            }
-        }
         emit deviceAdded(device->id());
     }
 
@@ -295,12 +277,15 @@ void DeviceManager::removeDevice(Core::Id id)
     }
     if (this == instance() && d->clonedInstance)
         d->clonedInstance->removeDevice(id);
-    if (this == instance() && device->isAutoDetected())
-        d->inactiveAutoDetectedDevices << device;
 
     emit updated();
 }
 
+bool DeviceManager::isLoaded() const
+{
+    return d->writer;
+}
+
 void DeviceManager::setDefaultDevice(int idx)
 {
     QTC_ASSERT(this != instance(), return);
@@ -333,11 +318,10 @@ const IDeviceFactory *DeviceManager::restoreFactory(const QVariantMap &map)
 
 DeviceManager::DeviceManager(bool isInstance) : d(new DeviceManagerPrivate)
 {
-    d->writer = new Utils::PersistentSettingsWriter(settingsFilePath(QLatin1String("/qtcreator/devices.xml")),
-                                                    QLatin1String("QtCreatorDevices"));
     if (isInstance) {
-        load();
         connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()), SLOT(save()));
+        QTC_CHECK(!DeviceManagerPrivate::instance);
+        DeviceManagerPrivate::instance = this;
     }
 }
 
@@ -375,22 +359,12 @@ IDevice::ConstPtr DeviceManager::find(Core::Id id) const
     return index == -1 ? IDevice::ConstPtr() : deviceAt(index);
 }
 
-IDevice::ConstPtr DeviceManager::findInactiveAutoDetectedDevice(Core::Id type, Core::Id id)
-{
-    return findAutoDetectedDevice(d->inactiveAutoDetectedDevices, type, id);
-}
-
 IDevice::ConstPtr DeviceManager::defaultDevice(Core::Id deviceType) const
 {
     const Core::Id id = d->defaultDevices.value(deviceType);
     return id.isValid() ? find(id) : IDevice::ConstPtr();
 }
 
-Core::Id DeviceManager::deviceId(const IDevice::ConstPtr &device) const
-{
-    return device ? device->id() : Core::Id();
-}
-
 void DeviceManager::ensureOneDefaultDevicePerType()
 {
     foreach (const IDevice::Ptr &device, d->devices) {
diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.h b/src/plugins/projectexplorer/devicesupport/devicemanager.h
index a57a0e03c364eb6e0a0ad5b346a2bd232749c3e0..bd52d0b9f62a814c2e52a76c40289dbcac4eff53 100644
--- a/src/plugins/projectexplorer/devicesupport/devicemanager.h
+++ b/src/plugins/projectexplorer/devicesupport/devicemanager.h
@@ -42,6 +42,8 @@ namespace ProjectExplorer {
 class IDevice;
 class IDeviceFactory;
 
+class ProjectExplorerPlugin;
+
 namespace Internal {
 class DeviceManagerPrivate;
 class DeviceSettingsWidget;
@@ -62,14 +64,14 @@ public:
     IDevice::ConstPtr deviceAt(int index) const;
 
     IDevice::ConstPtr find(Core::Id id) const;
-    IDevice::ConstPtr findInactiveAutoDetectedDevice(Core::Id type, Core::Id id);
     IDevice::ConstPtr defaultDevice(Core::Id deviceType) const;
     bool hasDevice(const QString &name) const;
-    Core::Id deviceId(const IDevice::ConstPtr &device) const;
 
-    void addDevice(const IDevice::Ptr &device);
+    void addDevice(const IDevice::ConstPtr &device);
     void removeDevice(Core::Id id);
 
+    bool isLoaded() const;
+
 signals:
     void deviceAdded(Core::Id id);
     void deviceRemoved(Core::Id id);
@@ -77,11 +79,13 @@ signals:
     void deviceListChanged();
     void updated(); // Emitted for all of the above.
 
+    void devicesLoaded(); // Emitted once load() is done
+
 private slots:
     void save();
 
 private:
-    DeviceManager(bool isInstance = false);
+    DeviceManager(bool isInstance = true);
 
     void load();
     static const IDeviceFactory *restoreFactory(const QVariantMap &map);
@@ -105,6 +109,9 @@ private:
     static void copy(const DeviceManager *source, DeviceManager *target, bool deep);
 
     Internal::DeviceManagerPrivate * const d;
+
+    friend class Internal::DeviceManagerPrivate;
+    friend class ProjectExplorerPlugin;
 };
 
 } // namespace ProjectExplorer
diff --git a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp
index 30364de23a230834c7a3c4ee5332dbb4bc2e60cc..ae94c018fe63b7038944eddcbc29076446eac250 100644
--- a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp
+++ b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp
@@ -213,7 +213,8 @@ void DeviceSettingsWidget::displayCurrent()
     }
     m_ui->deviceStateValueTextLabel->setText(current->deviceStateToString());
 
-    m_ui->removeConfigButton->setEnabled(!current->isAutoDetected());
+    m_ui->removeConfigButton->setEnabled(!current->isAutoDetected()
+            || current->deviceState() == IDevice::DeviceDisconnected);
     fillInValues();
 }
 
diff --git a/src/plugins/projectexplorer/kit.cpp b/src/plugins/projectexplorer/kit.cpp
index 5b2603784a981bab84519b0aa81eb787ed1d6ffd..0fa3881549818f0189528e0d8d86baefbbe0be32 100644
--- a/src/plugins/projectexplorer/kit.cpp
+++ b/src/plugins/projectexplorer/kit.cpp
@@ -216,16 +216,11 @@ void Kit::fix()
 void Kit::setup()
 {
     KitGuard g(this);
-    QHash<Core::Id, QVariant> data = d->m_data;
-    for (int i = 0; i < 5; ++i) {
-        // Allow for some retries to settle down in a good configuration
-        // This is necessary for the Qt version to pick its preferred tool chain
-        // and that to pick a working debugger afterwards.
-        foreach (KitInformation *i, KitManager::instance()->kitInformation())
-            i->setup(this);
-        if (d->m_data == data)
-            break;
-    }
+    // Process the KitInfos in reverse order: They may only be based on other information lower in
+    // the stack.
+    QList<KitInformation *> info = KitManager::instance()->kitInformation();
+    for (int i = info.count() - 1; i >= 0; --i)
+        info.at(i)->setup(this);
 }
 
 QString Kit::displayName() const
diff --git a/src/plugins/projectexplorer/kit.h b/src/plugins/projectexplorer/kit.h
index bd79ff3e83f5275599f297e1a377f56042070496..3bebca6fe6217f11229139ef37375e60c91608c6 100644
--- a/src/plugins/projectexplorer/kit.h
+++ b/src/plugins/projectexplorer/kit.h
@@ -66,7 +66,8 @@ public:
     bool isValid() const;
     bool hasWarning() const;
     QList<Task> validate() const;
-    void fix(); // Fix the individual kit information.
+    void fix(); // Fix the individual kit information: Make sure it contains a valid value.
+                // Fix will not look at other information in the kit!
     void setup(); // Apply advanced magic(TM). Used only once on each kit during initial setup.
 
     QString displayName() const;
diff --git a/src/plugins/projectexplorer/kitinformation.cpp b/src/plugins/projectexplorer/kitinformation.cpp
index 37a55d01394bc21a8566ba99b2608abfc8f04da3..bb64cc97c41f49e15bd21f99dc2c309022264a8b 100644
--- a/src/plugins/projectexplorer/kitinformation.cpp
+++ b/src/plugins/projectexplorer/kitinformation.cpp
@@ -40,6 +40,7 @@
 #include <extensionsystem/pluginmanager.h>
 #include <projectexplorer/abi.h>
 #include <utils/pathchooser.h>
+#include <utils/qtcassert.h>
 
 #include <QComboBox>
 #include <QHBoxLayout>
@@ -67,7 +68,7 @@ Core::Id SysRootKitInformation::dataId() const
 
 unsigned int SysRootKitInformation::priority() const
 {
-    return 32000;
+    return 31000;
 }
 
 QVariant SysRootKitInformation::defaultValue(Kit *k) const
@@ -125,12 +126,8 @@ static const char TOOLCHAIN_INFORMATION[] = "PE.Profile.ToolChain";
 ToolChainKitInformation::ToolChainKitInformation()
 {
     setObjectName(QLatin1String("ToolChainInformation"));
-    connect(ToolChainManager::instance(), SIGNAL(toolChainRemoved(ProjectExplorer::ToolChain*)),
-            this, SIGNAL(validationNeeded()));
-    connect(ToolChainManager::instance(), SIGNAL(toolChainUpdated(ProjectExplorer::ToolChain*)),
-            this, SIGNAL(validationNeeded()));
-    connect(ToolChainManager::instance(), SIGNAL(toolChainUpdated(ProjectExplorer::ToolChain*)),
-            this, SLOT(toolChainUpdated(ProjectExplorer::ToolChain*)));
+    connect(KitManager::instance(), SIGNAL(kitsLoaded()),
+            this, SLOT(kitsWereLoaded()));
 }
 
 Core::Id ToolChainKitInformation::dataId() const
@@ -173,6 +170,7 @@ QList<Task> ToolChainKitInformation::validate(const Kit *k) const
 
 void ToolChainKitInformation::fix(Kit *k)
 {
+    QTC_ASSERT(ToolChainManager::instance()->isLoaded(), return);
     if (toolChain(k))
         return;
 
@@ -183,6 +181,7 @@ void ToolChainKitInformation::fix(Kit *k)
 
 void ToolChainKitInformation::setup(Kit *k)
 {
+    QTC_ASSERT(ToolChainManager::instance()->isLoaded(), return);
     const QString id = k->value(Core::Id(TOOLCHAIN_INFORMATION)).toString();
     if (id.isEmpty())
         return;
@@ -232,6 +231,7 @@ IOutputParser *ToolChainKitInformation::createOutputParser(const Kit *k) const
 
 ToolChain *ToolChainKitInformation::toolChain(const Kit *k)
 {
+    QTC_ASSERT(ToolChainManager::instance()->isLoaded(), return 0);
     if (!k)
         return 0;
     return ToolChainManager::instance()
@@ -248,11 +248,29 @@ QString ToolChainKitInformation::msgNoToolChainInTarget()
     return tr("No compiler set in kit.");
 }
 
-void ToolChainKitInformation::toolChainUpdated(ToolChain *tc)
+void ToolChainKitInformation::kitsWereLoaded()
 {
     foreach (Kit *k, KitManager::instance()->kits())
-        if (toolChain(k) == tc)
-            notifyAboutUpdate(k);
+        fix(k);
+
+    connect(ToolChainManager::instance(), SIGNAL(toolChainRemoved(ProjectExplorer::ToolChain*)),
+            this, SLOT(toolChainRemoved(ProjectExplorer::ToolChain*)));
+    connect(ToolChainManager::instance(), SIGNAL(toolChainUpdated(ProjectExplorer::ToolChain*)),
+            this, SLOT(toolChainUpdated(ProjectExplorer::ToolChain*)));
+}
+
+void ToolChainKitInformation::toolChainUpdated(ProjectExplorer::ToolChain *tc)
+{
+    ToolChainMatcher m(tc);
+    foreach (Kit *k, KitManager::instance()->kits(&m))
+        notifyAboutUpdate(k);
+}
+
+void ToolChainKitInformation::toolChainRemoved(ProjectExplorer::ToolChain *tc)
+{
+    Q_UNUSED(tc);
+    foreach (Kit *k, KitManager::instance()->kits())
+        fix(k);
 }
 
 // --------------------------------------------------------------------------
@@ -336,12 +354,8 @@ static const char DEVICE_INFORMATION[] = "PE.Profile.Device";
 DeviceKitInformation::DeviceKitInformation()
 {
     setObjectName(QLatin1String("DeviceInformation"));
-    connect(DeviceManager::instance(), SIGNAL(deviceRemoved(Core::Id)),
-            this, SIGNAL(validationNeeded()));
-    connect(DeviceManager::instance(), SIGNAL(deviceUpdated(Core::Id)),
-            this, SIGNAL(validationNeeded()));
-    connect(DeviceManager::instance(), SIGNAL(deviceUpdated(Core::Id)),
-            this, SLOT(deviceUpdated(Core::Id)));
+    connect(KitManager::instance(), SIGNAL(kitsLoaded()),
+            this, SLOT(kitsWereLoaded()));
 }
 
 Core::Id DeviceKitInformation::dataId() const
@@ -381,6 +395,17 @@ void DeviceKitInformation::fix(Kit *k)
     if (!dev.isNull() && dev->type() == DeviceTypeKitInformation::deviceTypeId(k))
         return;
 
+    qWarning("Device is no longer known, removing from kit \"%s\".", qPrintable(k->displayName()));
+    setDeviceId(k, Core::Id());
+}
+
+void DeviceKitInformation::setup(Kit *k)
+{
+    QTC_ASSERT(DeviceManager::instance()->isLoaded(), return);
+    IDevice::ConstPtr dev = DeviceKitInformation::device(k);
+    if (!dev.isNull() && dev->type() == DeviceTypeKitInformation::deviceTypeId(k))
+        return;
+
     setDeviceId(k, Core::Id::fromSetting(defaultValue(k)));
 }
 
@@ -403,8 +428,8 @@ KitInformation::ItemList DeviceKitInformation::toUserOutput(const Kit *k) const
 
 IDevice::ConstPtr DeviceKitInformation::device(const Kit *k)
 {
-    DeviceManager *dm = DeviceManager::instance();
-    return dm ? dm->find(deviceId(k)) : IDevice::ConstPtr();
+    QTC_ASSERT(DeviceManager::instance()->isLoaded(), return IDevice::ConstPtr());
+    return DeviceManager::instance()->find(deviceId(k));
 }
 
 Core::Id DeviceKitInformation::deviceId(const Kit *k)
@@ -422,11 +447,51 @@ void DeviceKitInformation::setDeviceId(Kit *k, const Core::Id id)
     k->setValue(DEVICE_INFORMATION, id.toSetting());
 }
 
-void DeviceKitInformation::deviceUpdated(const Core::Id &id)
+void DeviceKitInformation::kitsWereLoaded()
 {
     foreach (Kit *k, KitManager::instance()->kits())
+        fix(k);
+
+    connect(DeviceManager::instance(), SIGNAL(deviceAdded(Core::Id)),
+            this, SLOT(deviceAdded(Core::Id)));
+    connect(DeviceManager::instance(), SIGNAL(deviceRemoved(Core::Id)),
+            this, SLOT(deviceRemoved(Core::Id)));
+    connect(DeviceManager::instance(), SIGNAL(deviceUpdated(Core::Id)),
+            this, SLOT(deviceUpdated(Core::Id)));
+
+    connect(KitManager::instance(), SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
+            this, SLOT(kitUpdated(ProjectExplorer::Kit*)));
+    connect(KitManager::instance(), SIGNAL(unmanagedKitUpdated(ProjectExplorer::Kit*)),
+            this, SLOT(kitUpdated(ProjectExplorer::Kit*)));
+}
+
+void DeviceKitInformation::deviceUpdated(const Core::Id &id)
+{
+    foreach (Kit *k, KitManager::instance()->kits()) {
         if (deviceId(k) == id)
             notifyAboutUpdate(k);
+    }
+}
+
+void DeviceKitInformation::kitUpdated(Kit *k)
+{
+    setup(k); // Set default device if necessary
+}
+
+void DeviceKitInformation::deviceAdded(const Core::Id &id)
+{
+    Q_UNUSED(id);
+    DeviceMatcher m;
+    foreach (Kit *k, KitManager::instance()->kits(&m)) {
+        setup(k); // Set default device if necessary
+    }
+}
+
+void DeviceKitInformation::deviceRemoved(const Core::Id &id)
+{
+    DeviceMatcher m(id);
+    foreach (Kit *k, KitManager::instance()->kits(&m))
+        setup(k); // Set default device if necessary
 }
 
 } // namespace ProjectExplorer
diff --git a/src/plugins/projectexplorer/kitinformation.h b/src/plugins/projectexplorer/kitinformation.h
index aa121fce55826da85baaf023bca4e0e65fe47b93..6f7e8006d296664be2330f1e1fd6965a463dffd2 100644
--- a/src/plugins/projectexplorer/kitinformation.h
+++ b/src/plugins/projectexplorer/kitinformation.h
@@ -120,7 +120,9 @@ public:
 
     static QString msgNoToolChainInTarget();
 private slots:
+    void kitsWereLoaded();
     void toolChainUpdated(ProjectExplorer::ToolChain *tc);
+    void toolChainRemoved(ProjectExplorer::ToolChain *tc);
 };
 
 class PROJECTEXPLORER_EXPORT ToolChainMatcher : public KitMatcher
@@ -200,6 +202,7 @@ public:
 
     QList<Task> validate(const Kit *k) const;
     void fix(Kit *k);
+    void setup(Kit *k);
 
     KitConfigWidget *createConfigWidget(Kit *k) const;
 
@@ -211,8 +214,13 @@ public:
     static Core::Id deviceId(const Kit *k);
     static void setDevice(Kit *k, IDevice::ConstPtr dev);
     static void setDeviceId(Kit *k, const Core::Id id);
+
 private slots:
+    void kitsWereLoaded();
+    void deviceAdded(const Core::Id &id);
+    void deviceRemoved(const Core::Id &id);
     void deviceUpdated(const Core::Id &id);
+    void kitUpdated(ProjectExplorer::Kit *k);
 };
 
 class PROJECTEXPLORER_EXPORT DeviceMatcher : public KitMatcher
@@ -221,6 +229,8 @@ public:
     DeviceMatcher(Core::Id id) : m_devId(id)
     { }
 
+    DeviceMatcher() { }
+
     bool matches(const Kit *k) const
     {
         return DeviceKitInformation::deviceId(k) == m_devId;
diff --git a/src/plugins/projectexplorer/kitinformationconfigwidget.cpp b/src/plugins/projectexplorer/kitinformationconfigwidget.cpp
index 9945c31b1883d2ea5a071ec4104ea1ae9bd2e7fd..5ee3f6483b973d0391e6eb41807f783c49365332 100644
--- a/src/plugins/projectexplorer/kitinformationconfigwidget.cpp
+++ b/src/plugins/projectexplorer/kitinformationconfigwidget.cpp
@@ -346,15 +346,19 @@ void DeviceInformationConfigWidget::manageDevices()
 void DeviceInformationConfigWidget::modelAboutToReset()
 {
     m_selectedId = m_model->deviceId(m_comboBox->currentIndex());
+    m_ignoreChange = true;
 }
 
 void DeviceInformationConfigWidget::modelReset()
 {
     m_comboBox->setCurrentIndex(m_model->indexForId(m_selectedId));
+    m_ignoreChange = false;
 }
 
 void DeviceInformationConfigWidget::currentDeviceChanged()
 {
+    if (m_ignoreChange)
+        return;
     DeviceKitInformation::setDeviceId(m_kit, m_model->deviceId(m_comboBox->currentIndex()));
 }
 
diff --git a/src/plugins/projectexplorer/kitinformationconfigwidget.h b/src/plugins/projectexplorer/kitinformationconfigwidget.h
index 0b8ea8696a67d8232a13879b4b9d8bf8df89b1fc..3838c3aede9d31764623f73c3db9e0fcde7a5ece 100644
--- a/src/plugins/projectexplorer/kitinformationconfigwidget.h
+++ b/src/plugins/projectexplorer/kitinformationconfigwidget.h
@@ -159,6 +159,7 @@ private slots:
 
 private:
     bool m_isReadOnly;
+    bool m_ignoreChange;
     QComboBox *m_comboBox;
     QPushButton *m_manageButton;
     DeviceManagerModel *m_model;
diff --git a/src/plugins/projectexplorer/kitmanager.cpp b/src/plugins/projectexplorer/kitmanager.cpp
index 7166b5ff0bbfcf39ea3e3ea61d107db6f1af88bc..a4247be4c983abe1a93b66c711fff06bb02af0da 100644
--- a/src/plugins/projectexplorer/kitmanager.cpp
+++ b/src/plugins/projectexplorer/kitmanager.cpp
@@ -39,7 +39,6 @@
 #include <coreplugin/icore.h>
 
 #include <extensionsystem/pluginmanager.h>
-#include <extensionsystem/pluginspec.h>
 
 #include <utils/persistentsettings.h>
 #include <utils/environment.h>
@@ -139,7 +138,6 @@ void KitManager::restoreKits()
         return;
 
     initializing = true;
-    QTC_CHECK(ProjectExplorerPlugin::instance()->pluginSpec()->state() == ExtensionSystem::PluginSpec::Running);
 
     QList<Kit *> kitsToRegister;
     QList<Kit *> kitsToValidate;
@@ -221,6 +219,7 @@ void KitManager::restoreKits()
 
     d->m_writer = new Utils::PersistentSettingsWriter(settingsFileName(), QLatin1String("QtCreatorProfiles"));
     d->m_initialized = true;
+    emit kitsLoaded();
     emit kitsChanged();
 }
 
@@ -264,15 +263,12 @@ bool greaterPriority(KitInformation *a, KitInformation *b)
 
 void KitManager::registerKitInformation(KitInformation *ki)
 {
-    QTC_CHECK(ProjectExplorerPlugin::instance()->pluginSpec()->state() <= ExtensionSystem::PluginSpec::Initialized);
-    QTC_CHECK(d->m_kitList.isEmpty());
+    QTC_CHECK(!isLoaded());
 
     QList<KitInformation *>::iterator it
             = qLowerBound(d->m_informationList.begin(), d->m_informationList.end(), ki, greaterPriority);
     d->m_informationList.insert(it, ki);
 
-    connect(ki, SIGNAL(validationNeeded()), this, SLOT(validateKits()));
-
     if (!d->m_initialized)
         return;
 
@@ -344,9 +340,6 @@ KitManager::KitList KitManager::restoreKits(const Utils::FileName &fileName)
 
 QList<Kit *> KitManager::kits(const KitMatcher *m) const
 {
-    if (!d->m_initialized)
-        const_cast<KitManager *>(this)->restoreKits();
-
     QList<Kit *> result;
     foreach (Kit *k, d->m_kitList) {
         if (!m || m->matches(k))
@@ -375,8 +368,6 @@ Kit *KitManager::find(const KitMatcher *m) const
 
 Kit *KitManager::defaultKit() const
 {
-    if (!d->m_initialized)
-        const_cast<KitManager *>(this)->restoreKits();
     return d->m_defaultKit;
 }
 
@@ -402,6 +393,11 @@ void KitManager::deleteKit(Kit *k)
     delete k;
 }
 
+bool KitManager::isLoaded() const
+{
+    return d->m_initialized;
+}
+
 void KitManager::notifyAboutUpdate(ProjectExplorer::Kit *k)
 {
     if (!k)
@@ -414,6 +410,7 @@ void KitManager::notifyAboutUpdate(ProjectExplorer::Kit *k)
 
 bool KitManager::registerKit(ProjectExplorer::Kit *k)
 {
+    QTC_ASSERT(isLoaded(), return false);
     if (!k)
         return true;
     foreach (Kit *current, kits()) {
@@ -460,12 +457,6 @@ void KitManager::setDefaultKit(Kit *k)
         emit defaultkitChanged();
 }
 
-void KitManager::validateKits()
-{
-    foreach (Kit *k, d->m_kitList) // no need to load kits just to validate them!
-        k->validate();
-}
-
 void KitManager::addKit(Kit *k)
 {
     if (!k)
diff --git a/src/plugins/projectexplorer/kitmanager.h b/src/plugins/projectexplorer/kitmanager.h
index 9d43771e0cfe868d3147f6c17cee07f23977c239..d585c5bc10a8e8a835d85d7fcf23774a2bc48a37 100644
--- a/src/plugins/projectexplorer/kitmanager.h
+++ b/src/plugins/projectexplorer/kitmanager.h
@@ -92,9 +92,6 @@ public:
 
 protected:
     void notifyAboutUpdate(Kit *k);
-
-signals:
-    void validationNeeded();
 };
 
 class PROJECTEXPLORER_EXPORT KitMatcher
@@ -123,6 +120,8 @@ public:
 
     static void deleteKit(Kit *k);
 
+    bool isLoaded() const;
+
 public slots:
     bool registerKit(ProjectExplorer::Kit *k);
     void deregisterKit(ProjectExplorer::Kit *k);
@@ -145,8 +144,7 @@ signals:
     // Something changed.
     void kitsChanged();
 
-private slots:
-    void validateKits();
+    void kitsLoaded();
 
 private:
     explicit KitManager(QObject *parent = 0);
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index 105e806996c87abf87100bd9db68b47aa8ae9b03..ff3244c462025382ac02b75105822115330c8178 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -344,7 +344,15 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
     addAutoReleasedObject(new Internal::DesktopDeviceFactory);
 
     d->m_kitManager = new KitManager; // register before ToolChainManager
+    new DeviceManager; // Create DeviceManager singleton
     d->m_toolChainManager = new ToolChainManager;
+
+    // Register KitInformation:
+    KitManager::instance()->registerKitInformation(new DeviceTypeKitInformation);
+    KitManager::instance()->registerKitInformation(new DeviceKitInformation);
+    KitManager::instance()->registerKitInformation(new ToolChainKitInformation);
+    KitManager::instance()->registerKitInformation(new SysRootKitInformation);
+
     addAutoReleasedObject(new Internal::ToolChainOptionsPage);
     addAutoReleasedObject(new KitOptionsPage);
 
@@ -1116,16 +1124,10 @@ void ProjectExplorerPlugin::extensionsInitialized()
     }
     d->m_buildManager->extensionsInitialized();
 
-    // Register KitInformation:
-    // Only do this now to make sure all device factories were properly initialized.
-    KitManager::instance()->registerKitInformation(new SysRootKitInformation);
-    KitManager::instance()->registerKitInformation(new DeviceKitInformation);
-    KitManager::instance()->registerKitInformation(new DeviceTypeKitInformation);
-    KitManager::instance()->registerKitInformation(new ToolChainKitInformation);
-
-    DeviceManager *dm = DeviceManager::instance();
-    if (dm->find(Core::Id(Constants::DESKTOP_DEVICE_ID)).isNull())
-        DeviceManager::instance()->addDevice(IDevice::Ptr(new DesktopDevice));
+    DeviceManager::instance()->addDevice(IDevice::Ptr(new DesktopDevice));
+    DeviceManager::instance()->load();
+    d->m_toolChainManager->restoreToolChains();
+    d->m_kitManager->restoreKits();
 }
 
 void ProjectExplorerPlugin::loadCustomWizards()
diff --git a/src/plugins/projectexplorer/toolchainmanager.cpp b/src/plugins/projectexplorer/toolchainmanager.cpp
index f8db099b3dd9d2fa42bc7bb9548fb54409dbad76..e24bef00e8d8183e531c430c2f330b4f8bf2135c 100644
--- a/src/plugins/projectexplorer/toolchainmanager.cpp
+++ b/src/plugins/projectexplorer/toolchainmanager.cpp
@@ -80,13 +80,10 @@ public:
     ToolChainManagerPrivate(ToolChainManager *parent);
     ~ToolChainManagerPrivate();
 
-    QList<ToolChain *> &toolChains();
-
     ToolChainManager *q;
     QMap<QString, Utils::FileName> m_abiToDebugger;
     Utils::PersistentSettingsWriter *m_writer;
 
-private:
     QList<ToolChain *> m_toolChains;
 };
 
@@ -101,13 +98,6 @@ ToolChainManagerPrivate::~ToolChainManagerPrivate()
     delete m_writer;
 }
 
-QList<ToolChain *> &ToolChainManagerPrivate::toolChains()
-{
-    if (!m_writer)
-        q->restoreToolChains();
-    return m_toolChains;
-}
-
 } // namespace Internal
 
 // --------------------------------------------------------------------------
@@ -139,7 +129,6 @@ ToolChainManager::ToolChainManager(QObject *parent) :
 void ToolChainManager::restoreToolChains()
 {
     QTC_ASSERT(!d->m_writer, return);
-    QTC_CHECK(ProjectExplorerPlugin::instance()->pluginSpec()->state() == ExtensionSystem::PluginSpec::Running);
     d->m_writer =
             new Utils::PersistentSettingsWriter(settingsFileName(QLatin1String(TOOLCHAIN_FILENAME)), QLatin1String("QtCreatorToolChains"));
 
@@ -209,6 +198,8 @@ void ToolChainManager::restoreToolChains()
     // Store manual tool chains
     foreach (ToolChain *tc, tcsToRegister)
         registerToolChain(tc);
+
+    emit toolChainsLoaded();
 }
 
 ToolChainManager::~ToolChainManager()
@@ -223,7 +214,7 @@ void ToolChainManager::saveToolChains()
     data.insert(QLatin1String(TOOLCHAIN_FILE_VERSION_KEY), 1);
 
     int count = 0;
-    foreach (ToolChain *tc, d->toolChains()) {
+    foreach (ToolChain *tc, d->m_toolChains) {
         if (tc->isValid()) {
             QVariantMap tmp = tc->toMap();
             if (tmp.isEmpty())
@@ -290,18 +281,19 @@ QList<ToolChain *> ToolChainManager::restoreToolChains(const Utils::FileName &fi
                      qPrintable(ToolChainFactory::idFromMap(tcMap)),
                      qPrintable(fileName.toUserOutput()));
     }
+
     return result;
 }
 
 QList<ToolChain *> ToolChainManager::toolChains() const
 {
-    return d->toolChains();
+    return d->m_toolChains;
 }
 
 QList<ToolChain *> ToolChainManager::findToolChains(const Abi &abi) const
 {
     QList<ToolChain *> result;
-    foreach (ToolChain *tc, toolChains()) {
+    foreach (ToolChain *tc, d->m_toolChains) {
         Abi targetAbi = tc->targetAbi();
         if (targetAbi.isCompatibleWith(abi))
             result.append(tc);
@@ -314,7 +306,7 @@ ToolChain *ToolChainManager::findToolChain(const QString &id) const
     if (id.isEmpty())
         return 0;
 
-    foreach (ToolChain *tc, d->toolChains()) {
+    foreach (ToolChain *tc, d->m_toolChains) {
         if (tc->id() == id)
             return tc;
     }
@@ -326,32 +318,39 @@ Utils::FileName ToolChainManager::defaultDebugger(const Abi &abi) const
     return d->m_abiToDebugger.value(abi.toString());
 }
 
+bool ToolChainManager::isLoaded() const
+{
+    return d->m_writer;
+}
+
 void ToolChainManager::notifyAboutUpdate(ProjectExplorer::ToolChain *tc)
 {
-    if (!tc || !toolChains().contains(tc))
+    if (!tc || !d->m_toolChains.contains(tc))
         return;
     emit toolChainUpdated(tc);
 }
 
 bool ToolChainManager::registerToolChain(ToolChain *tc)
 {
-    if (!tc || d->toolChains().contains(tc))
+    QTC_ASSERT(d->m_writer, return false);
+
+    if (!tc || d->m_toolChains.contains(tc))
         return true;
-    foreach (ToolChain *current, d->toolChains()) {
+    foreach (ToolChain *current, d->m_toolChains) {
         if (*tc == *current && !tc->isAutoDetected())
             return false;
     }
 
-    d->toolChains().append(tc);
+    d->m_toolChains.append(tc);
     emit toolChainAdded(tc);
     return true;
 }
 
 void ToolChainManager::deregisterToolChain(ToolChain *tc)
 {
-    if (!tc || !d->toolChains().contains(tc))
+    if (!tc || !d->m_toolChains.contains(tc))
         return;
-    d->toolChains().removeOne(tc);
+    d->m_toolChains.removeOne(tc);
     emit toolChainRemoved(tc);
     delete tc;
 }
diff --git a/src/plugins/projectexplorer/toolchainmanager.h b/src/plugins/projectexplorer/toolchainmanager.h
index f16df41b746fa1f5d9a6374e268b0d93b7a098b3..58a656c325cfe3e0bd996df0e2293dee0abfde30 100644
--- a/src/plugins/projectexplorer/toolchainmanager.h
+++ b/src/plugins/projectexplorer/toolchainmanager.h
@@ -66,6 +66,8 @@ public:
 
     Utils::FileName defaultDebugger(const Abi &abi) const;
 
+    bool isLoaded() const;
+
 public slots:
     bool registerToolChain(ProjectExplorer::ToolChain *tc);
     void deregisterToolChain(ProjectExplorer::ToolChain *tc);
@@ -81,6 +83,8 @@ signals:
     // Something changed:
     void toolChainsChanged();
 
+    void toolChainsLoaded();
+
 private:
     explicit ToolChainManager(QObject *parent = 0);
 
diff --git a/src/plugins/qbsprojectmanager/qbscleanstep.cpp b/src/plugins/qbsprojectmanager/qbscleanstep.cpp
index 4b33f65c3a85f81601cd27f442caa550f21acc17..2611537ce32db1f75ba5ba48a70c588a0c51a85e 100644
--- a/src/plugins/qbsprojectmanager/qbscleanstep.cpp
+++ b/src/plugins/qbsprojectmanager/qbscleanstep.cpp
@@ -44,7 +44,6 @@
 static const char QBS_CLEAN_ALL[] = "Qbs.CleanAll";
 static const char QBS_DRY_RUN[] = "Qbs.DryRun";
 static const char QBS_KEEP_GOING[] = "Qbs.DryKeepGoing";
-static const char QBS_MAXJOBCOUNT[] = "Qbs.MaxJobs";
 
 // --------------------------------------------------------------------
 // Constants:
@@ -59,14 +58,14 @@ namespace Internal {
 
 QbsCleanStep::QbsCleanStep(ProjectExplorer::BuildStepList *bsl) :
     ProjectExplorer::BuildStep(bsl, Core::Id(Constants::QBS_CLEANSTEP_ID)),
-    m_cleanAll(false), m_job(0), m_showCompilerOutput(true), m_parser(0)
+    m_job(0), m_showCompilerOutput(true), m_parser(0)
 {
     setDisplayName(tr("Qbs clean"));
 }
 
 QbsCleanStep::QbsCleanStep(ProjectExplorer::BuildStepList *bsl, const QbsCleanStep *other) :
     ProjectExplorer::BuildStep(bsl, Core::Id(Constants::QBS_CLEANSTEP_ID)),
-    m_qbsBuildOptions(other->m_qbsBuildOptions), m_cleanAll(other->m_cleanAll), m_job(0),
+    m_qbsCleanOptions(other->m_qbsCleanOptions), m_job(0),
     m_showCompilerOutput(other->m_showCompilerOutput), m_parser(0)
 { }
 
@@ -97,9 +96,9 @@ void QbsCleanStep::run(QFutureInterface<bool> &fi)
     m_fi = &fi;
 
     QbsProject *pro = static_cast<QbsProject *>(project());
-    qbs::BuildOptions options(m_qbsBuildOptions);
+    qbs::CleanOptions options(m_qbsCleanOptions);
 
-    m_job = pro->clean(options, m_cleanAll);
+    m_job = pro->clean(options);
 
     if (!m_job) {
         m_fi->reportResult(false);
@@ -133,22 +132,22 @@ void QbsCleanStep::cancel()
 
 bool QbsCleanStep::dryRun() const
 {
-    return m_qbsBuildOptions.dryRun;
+    return m_qbsCleanOptions.dryRun;
 }
 
 bool QbsCleanStep::keepGoing() const
 {
-    return m_qbsBuildOptions.keepGoing;
+    return m_qbsCleanOptions.keepGoing;
 }
 
 int QbsCleanStep::maxJobs() const
 {
-    return m_qbsBuildOptions.maxJobCount;
+    return 1;
 }
 
 bool QbsCleanStep::cleanAll() const
 {
-    return m_cleanAll;
+    return m_qbsCleanOptions.cleanType == qbs::CleanOptions::CleanupAll;
 }
 
 bool QbsCleanStep::fromMap(const QVariantMap &map)
@@ -156,10 +155,10 @@ bool QbsCleanStep::fromMap(const QVariantMap &map)
     if (!ProjectExplorer::BuildStep::fromMap(map))
         return false;
 
-    m_qbsBuildOptions.dryRun = map.value(QLatin1String(QBS_DRY_RUN)).toBool();
-    m_qbsBuildOptions.keepGoing = map.value(QLatin1String(QBS_KEEP_GOING)).toBool();
-    m_qbsBuildOptions.maxJobCount = map.value(QLatin1String(QBS_MAXJOBCOUNT)).toInt();
-    m_cleanAll = map.value(QLatin1String(QBS_CLEAN_ALL)).toBool();
+    m_qbsCleanOptions.dryRun = map.value(QLatin1String(QBS_DRY_RUN)).toBool();
+    m_qbsCleanOptions.keepGoing = map.value(QLatin1String(QBS_KEEP_GOING)).toBool();
+    m_qbsCleanOptions.cleanType = map.value(QLatin1String(QBS_CLEAN_ALL)).toBool()
+            ? qbs::CleanOptions::CleanupAll : qbs::CleanOptions::CleanupTemporaries;
 
     return true;
 }
@@ -167,10 +166,10 @@ bool QbsCleanStep::fromMap(const QVariantMap &map)
 QVariantMap QbsCleanStep::toMap() const
 {
     QVariantMap map = ProjectExplorer::BuildStep::toMap();
-    map.insert(QLatin1String(QBS_DRY_RUN), m_qbsBuildOptions.dryRun);
-    map.insert(QLatin1String(QBS_KEEP_GOING), m_qbsBuildOptions.keepGoing);
-    map.insert(QLatin1String(QBS_MAXJOBCOUNT), m_qbsBuildOptions.maxJobCount);
-    map.insert(QLatin1String(QBS_CLEAN_ALL), m_cleanAll);
+    map.insert(QLatin1String(QBS_DRY_RUN), m_qbsCleanOptions.dryRun);
+    map.insert(QLatin1String(QBS_KEEP_GOING), m_qbsCleanOptions.keepGoing);
+    map.insert(QLatin1String(QBS_CLEAN_ALL),
+               m_qbsCleanOptions.cleanType == qbs::CleanOptions::CleanupAll);
 
     return map;
 }
@@ -216,33 +215,33 @@ void QbsCleanStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, con
 
 void QbsCleanStep::setDryRun(bool dr)
 {
-    if (m_qbsBuildOptions.dryRun == dr)
+    if (m_qbsCleanOptions.dryRun == dr)
         return;
-    m_qbsBuildOptions.dryRun = dr;
+    m_qbsCleanOptions.dryRun = dr;
     emit changed();
 }
 
 void QbsCleanStep::setKeepGoing(bool kg)
 {
-    if (m_qbsBuildOptions.keepGoing == kg)
+    if (m_qbsCleanOptions.keepGoing == kg)
         return;
-    m_qbsBuildOptions.keepGoing = kg;
+    m_qbsCleanOptions.keepGoing = kg;
     emit changed();
 }
 
 void QbsCleanStep::setMaxJobs(int jobcount)
 {
-    if (m_qbsBuildOptions.maxJobCount == jobcount)
-        return;
-    m_qbsBuildOptions.maxJobCount = jobcount;
+    Q_UNUSED(jobcount); // TODO: Remove all job count-related stuff.
     emit changed();
 }
 
 void QbsCleanStep::setCleanAll(bool ca)
 {
-    if (m_cleanAll == ca)
+    qbs::CleanOptions::CleanType newType = ca
+            ? qbs::CleanOptions::CleanupAll : qbs::CleanOptions::CleanupTemporaries;
+    if (m_qbsCleanOptions.cleanType == newType)
         return;
-    m_cleanAll = ca;
+    m_qbsCleanOptions.cleanType = newType;
     emit changed();
 }
 
diff --git a/src/plugins/qbsprojectmanager/qbscleanstep.h b/src/plugins/qbsprojectmanager/qbscleanstep.h
index 427e0692607890f6de22627c195ccee9dd6be9e6..57c9b138b7822fead0a19f5e42935f9ff02e98a7 100644
--- a/src/plugins/qbsprojectmanager/qbscleanstep.h
+++ b/src/plugins/qbsprojectmanager/qbscleanstep.h
@@ -84,8 +84,7 @@ private:
     void setMaxJobs(int jobcount);
     void setCleanAll(bool ca);
 
-    qbs::BuildOptions m_qbsBuildOptions;
-    bool m_cleanAll;
+    qbs::CleanOptions m_qbsCleanOptions;
 
     QFutureInterface<bool> *m_fi;
     qbs::CleanJob *m_job;
diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp
index cc132e929df244cc0702216ba9c039d6e32a4188..2cc9d996274176ed6b913d0cecf1c209be10fa95 100644
--- a/src/plugins/qbsprojectmanager/qbsproject.cpp
+++ b/src/plugins/qbsprojectmanager/qbsproject.cpp
@@ -177,12 +177,11 @@ qbs::BuildJob *QbsProject::build(const qbs::BuildOptions &opts)
     return m_rootProjectNode->project()->buildAllProducts(opts, env);
 }
 
-qbs::CleanJob *QbsProject::clean(const qbs::BuildOptions &opts, bool everything)
+qbs::CleanJob *QbsProject::clean(const qbs::CleanOptions &opts)
 {
     if (!m_rootProjectNode || !m_rootProjectNode->project())
         return 0;
-    return m_rootProjectNode->project()->cleanAllProducts(opts, everything ? qbs::Project::CleanupAll
-                                                                           : qbs::Project::CleanupTemporaries);
+    return m_rootProjectNode->project()->cleanAllProducts(opts);
 }
 
 QString QbsProject::profileForTarget(const ProjectExplorer::Target *t) const
diff --git a/src/plugins/qbsprojectmanager/qbsproject.h b/src/plugins/qbsprojectmanager/qbsproject.h
index 1c98a04ab3c7ba5ab912d6c003e890d58567b2e9..81b2e116a6bead852e784e9a32ed99cf112a04c7 100644
--- a/src/plugins/qbsprojectmanager/qbsproject.h
+++ b/src/plugins/qbsprojectmanager/qbsproject.h
@@ -80,7 +80,7 @@ public:
     QStringList files(FilesMode fileMode) const;
 
     qbs::BuildJob *build(const qbs::BuildOptions &opts);
-    qbs::CleanJob *clean(const qbs::BuildOptions &opts, bool everything);
+    qbs::CleanJob *clean(const qbs::CleanOptions &opts);
 
     static ProjectExplorer::FileType fileTypeFor(const QSet<QString> &tags);
 
diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.pro b/src/plugins/qbsprojectmanager/qbsprojectmanager.pro
index d179d8aa36b2634bc8491de062ff1c8e0ab20544..5cbbc02d7ba659755d8059473c3cef0ed9297f53 100644
--- a/src/plugins/qbsprojectmanager/qbsprojectmanager.pro
+++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.pro
@@ -6,16 +6,14 @@ include(../../libs/qmljs/qmljs.pri)
 include(qbsprojectmanager_dependencies.pri)
 
 # Look for qbs in the environment (again)
-isEmpty(QBS_SOURCE_DIR): QBS_SOURCE_DIR = $$(QBS_SOURCE_DIR)
-isEmpty(QBS_BUILD_DIR): QBS_BUILD_DIR = $$(QBS_BUILD_DIR)
+QBS_SOURCE_DIR = $$PWD/../../shared/qbs
+QBS_BUILD_DIR = $$IDE_BUILD_TREE/src/shared/qbs
 
 QBSLIBDIR = $$QBS_BUILD_DIR/lib
 include($$QBS_SOURCE_DIR/src/lib/use.pri)
 linux-*:QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$$QBSLIBDIR\'
 macx:QMAKE_LFLAGS += -Wl,-rpath,$$QBSLIBDIR
 
-QBS_SOURCE_DIR_FWD_SLASHES = $$replace(QBS_SOURCE_DIR, \\\\, /)
-DEFINES += QBS_SOURCE_DIR=\\\"$$QBS_SOURCE_DIR_FWD_SLASHES\\\"
 QBS_BUILD_DIR_FWD_SLASHES = $$replace(QBS_BUILD_DIR, \\\\, /)
 DEFINES += QBS_BUILD_DIR=\\\"$$QBS_BUILD_DIR_FWD_SLASHES\\\"
 DEFINES += \
@@ -56,4 +54,3 @@ FORMS = \
     qbsbuildstepconfigwidget.ui \
     qbscleanstepconfigwidget.ui \
     qbsstepconfigwidget.ui
-
diff --git a/src/plugins/qnx/bardescriptordocument.cpp b/src/plugins/qnx/bardescriptordocument.cpp
index b2ad97d9bc80c74f2db3da067ed07a5d1511e838..3d4fb4abfee5a2b1856116f3b598dcfd8ec5893f 100644
--- a/src/plugins/qnx/bardescriptordocument.cpp
+++ b/src/plugins/qnx/bardescriptordocument.cpp
@@ -36,12 +36,13 @@
 #include "bardescriptordocumentnodehandlers.h"
 
 #include <coreplugin/editormanager/ieditor.h>
+#include <coreplugin/editormanager/editormanager.h>
 #include <utils/qtcassert.h>
 
-#include <QtCore/QFile>
-#include <QtCore/QFileInfo>
-#include <QtCore/QDir>
-#include <QtCore/QTextCodec>
+#include <QFile>
+#include <QFileInfo>
+#include <QDir>
+#include <QTextCodec>
 
 using namespace Qnx;
 using namespace Qnx::Internal;
@@ -70,6 +71,13 @@ BarDescriptorDocument::BarDescriptorDocument(BarDescriptorEditorWidget *editorWi
 
     // Assets
     registerNodeHandler(new BarDescriptorDocumentAssetNodeHandler(m_editorWidget));
+
+    // blackberry-nativepackager requires the XML file to be in UTF-8 encoding,
+    // force if possible
+    if (QTextCodec *defaultUTF8 = QTextCodec::codecForName("UTF-8"))
+        setCodec(defaultUTF8);
+    else
+        setCodec(Core::EditorManager::instance()->defaultTextCodec());
 }
 
 BarDescriptorDocument::~BarDescriptorDocument()
diff --git a/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp
index d9a1c6b871bcbbe83387b3372cd08f2f4c88ef83..f1fd6015c9716fb258f9694e2973cdedce3ee9e2 100644
--- a/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp
+++ b/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp
@@ -431,6 +431,7 @@ void Qt4RunConfigurationWidget::termToggled(bool on)
 
 void Qt4RunConfigurationWidget::qvfbToggled(bool on)
 {
+    Q_UNUSED(on);
     m_ignoreChange = true;
     m_ignoreChange = false;
 }
diff --git a/src/plugins/qtsupport/qtkitinformation.cpp b/src/plugins/qtsupport/qtkitinformation.cpp
index def3b7ccb3fe4994f0933bfd0c04b5c5501c8667..be4c95265951e5841145c27bda46b7fb78cdb280 100644
--- a/src/plugins/qtsupport/qtkitinformation.cpp
+++ b/src/plugins/qtsupport/qtkitinformation.cpp
@@ -35,6 +35,7 @@
 #include "qtparser.h"
 
 #include <utils/environment.h>
+#include <utils/qtcassert.h>
 
 namespace QtSupport {
 namespace Internal {
@@ -44,10 +45,8 @@ const char QT_INFORMATION[] = "QtSupport.QtInformation";
 QtKitInformation::QtKitInformation()
 {
     setObjectName(QLatin1String("QtKitInformation"));
-    connect(QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
-            this, SIGNAL(validationNeeded()));
-    connect(QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
-            this, SLOT(qtVersionsChanged(QList<int>,QList<int>,QList<int>)));
+    connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsLoaded()),
+            this, SLOT(kitsWereLoaded()));
 }
 
 Core::Id QtKitInformation::dataId() const
@@ -89,17 +88,22 @@ QVariant QtKitInformation::defaultValue(ProjectExplorer::Kit *k) const
 
 QList<ProjectExplorer::Task> QtKitInformation::validate(const ProjectExplorer::Kit *k) const
 {
+    QList<ProjectExplorer::Task> result;
+    QTC_ASSERT(QtVersionManager::instance()->isLoaded(), return result);
     BaseQtVersion *version = qtVersion(k);
     if (!version)
-        return QList<ProjectExplorer::Task>();
+        return result;
     return version->validateKit(k);
 }
 
 void QtKitInformation::fix(ProjectExplorer::Kit *k)
 {
+    QTC_ASSERT(QtVersionManager::instance()->isLoaded(), return);
     BaseQtVersion *version = qtVersion(k);
-    if (!version)
+    if (!version) {
+        qWarning("Qt version is no longer known, removing from kit \"%s\".", qPrintable(k->displayName()));
         setQtVersionId(k, -1);
+    }
 }
 
 ProjectExplorer::KitConfigWidget *QtKitInformation::createConfigWidget(ProjectExplorer::Kit *k) const
@@ -187,6 +191,15 @@ void QtKitInformation::qtVersionsChanged(const QList<int> &addedIds,
             notifyAboutUpdate(k);
 }
 
+void QtKitInformation::kitsWereLoaded()
+{
+    foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::instance()->kits())
+        fix(k);
+
+    connect(QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
+            this, SLOT(qtVersionsChanged(QList<int>,QList<int>,QList<int>)));
+}
+
 QtPlatformKitMatcher::QtPlatformKitMatcher(const QString &platform) :
     m_platform(platform)
 { }
diff --git a/src/plugins/qtsupport/qtkitinformation.h b/src/plugins/qtsupport/qtkitinformation.h
index f783789f4c20294a7802cd40938bd69f75a1ea44..d88593df0788499c50e42804bbd89218cca3be89 100644
--- a/src/plugins/qtsupport/qtkitinformation.h
+++ b/src/plugins/qtsupport/qtkitinformation.h
@@ -72,6 +72,7 @@ private slots:
     void qtVersionsChanged(const QList<int> &addedIds,
                            const QList<int> &removedIds,
                            const QList<int> &changedIds);
+    void kitsWereLoaded();
 };
 
 class QTSUPPORT_EXPORT QtPlatformKitMatcher : public ProjectExplorer::KitMatcher
diff --git a/src/plugins/qtsupport/qtsupportplugin.cpp b/src/plugins/qtsupport/qtsupportplugin.cpp
index cedb4773486d9fa3f7e42b90905cb133b926b557..793ae378f2576dc094e6b0d6f179c4655e81ab85 100644
--- a/src/plugins/qtsupport/qtsupportplugin.cpp
+++ b/src/plugins/qtsupport/qtsupportplugin.cpp
@@ -83,6 +83,8 @@ bool QtSupportPlugin::initialize(const QStringList &arguments, QString *errorMes
 
     addAutoReleasedObject(new CustomExecutableRunConfigurationFactory);
 
+    ProjectExplorer::KitManager::instance()->registerKitInformation(new QtKitInformation);
+
     return true;
 }
 
@@ -98,7 +100,6 @@ void QtSupportPlugin::extensionsInitialized()
             this, SLOT(updateVariable(QByteArray)));
 
     QtVersionManager::instance()->extensionsInitialized();
-    ProjectExplorer::KitManager::instance()->registerKitInformation(new QtKitInformation);
 }
 
 bool QtSupportPlugin::delayedInitialize()
diff --git a/src/plugins/qtsupport/qtversionmanager.cpp b/src/plugins/qtsupport/qtversionmanager.cpp
index 6c83b053f405f2ae87f3e508a9a36d3f7f2e0a79..4a97026564e04af41d99e184401aac6f1e612c9f 100644
--- a/src/plugins/qtsupport/qtversionmanager.cpp
+++ b/src/plugins/qtsupport/qtversionmanager.cpp
@@ -143,6 +143,7 @@ void QtVersionManager::extensionsInitialized()
         findSystemQt();
     }
 
+    emit qtVersionsLoaded();
     emit qtVersionsChanged(m_versions.keys(), QList<int>(), QList<int>());
     saveQtVersions();
 
@@ -162,6 +163,11 @@ bool QtVersionManager::delayedInitialize()
     return true;
 }
 
+bool QtVersionManager::isLoaded() const
+{
+    return m_writer;
+}
+
 QtVersionManager::~QtVersionManager()
 {
     delete m_writer;
@@ -232,6 +238,7 @@ bool QtVersionManager::restoreQtVersions()
                      qPrintable(filename.toUserOutput()));
     }
     ++m_idcount;
+
     return true;
 }
 
@@ -398,6 +405,7 @@ void QtVersionManager::findSystemQt()
 
 void QtVersionManager::addVersion(BaseQtVersion *version)
 {
+    QTC_ASSERT(m_writer, return);
     QTC_ASSERT(version != 0, return);
     if (m_versions.contains(version->uniqueId()))
         return;
@@ -453,6 +461,7 @@ int QtVersionManager::getUniqueId()
 QList<BaseQtVersion *> QtVersionManager::versions() const
 {
     QList<BaseQtVersion *> versions;
+    QTC_ASSERT(isLoaded(), return versions);
     foreach (BaseQtVersion *version, m_versions)
         versions << version;
     qSort(versions.begin(), versions.end(), &qtVersionNumberCompare);
@@ -462,6 +471,7 @@ QList<BaseQtVersion *> QtVersionManager::versions() const
 QList<BaseQtVersion *> QtVersionManager::validVersions() const
 {
     QList<BaseQtVersion *> results;
+    QTC_ASSERT(isLoaded(), return results);
     foreach (BaseQtVersion *v, m_versions) {
         if (v->isValid())
             results.append(v);
@@ -472,6 +482,7 @@ QList<BaseQtVersion *> QtVersionManager::validVersions() const
 
 bool QtVersionManager::isValidId(int id) const
 {
+    QTC_ASSERT(isLoaded(), return false);
     return m_versions.contains(id);
 }
 
@@ -508,6 +519,7 @@ QString QtVersionManager::displayNameForPlatform(const QString &string) const
 
 BaseQtVersion *QtVersionManager::version(int id) const
 {
+    QTC_ASSERT(isLoaded(), return 0);
     QMap<int, BaseQtVersion *>::const_iterator it = m_versions.find(id);
     if (it == m_versions.constEnd())
         return 0;
diff --git a/src/plugins/qtsupport/qtversionmanager.h b/src/plugins/qtsupport/qtversionmanager.h
index 6df52625978c05d1d9305da571c736a2973e061d..0701fd42c9f960b5ac55ef133ad1cdaf106158e4 100644
--- a/src/plugins/qtsupport/qtversionmanager.h
+++ b/src/plugins/qtsupport/qtversionmanager.h
@@ -68,6 +68,8 @@ public:
     void extensionsInitialized();
     bool delayedInitialize();
 
+    bool isLoaded() const;
+
     // This will *always* return at least one (Qt in Path), even if that is
     // unconfigured.
     QList<BaseQtVersion *> versions() const;
@@ -99,6 +101,7 @@ signals:
     // content of BaseQtVersion objects with qmake path might have changed
     void dumpUpdatedFor(const Utils::FileName &qmakeCommand);
     void qtVersionsChanged(const QList<int> &addedIds, const QList<int> &removedIds, const QList<int> &changedIds);
+    void qtVersionsLoaded();
 
 public slots:
     void updateDumpFor(const Utils::FileName &qmakeCommand);
diff --git a/src/plugins/texteditor/semantichighlighter.h b/src/plugins/texteditor/semantichighlighter.h
index 9def1c0db657d4b5a80e9f86cc6d1626868d0fb9..e068d3b351e14ac04709edca7707d63aaec2a27f 100644
--- a/src/plugins/texteditor/semantichighlighter.h
+++ b/src/plugins/texteditor/semantichighlighter.h
@@ -65,6 +65,15 @@ public:
         : line(0), column(0), length(0), kind(-1) {}
     Result(unsigned line, unsigned column, unsigned length, int kind)
         : line(line), column(column), length(length), kind(kind) {}
+
+    bool operator==(const Result& other) const
+    {
+        return
+            line == other.line &&
+            column == other.column &&
+            length == other.length &&
+            kind == other.kind;
+    }
 };
 
 // Applies the future results [from, to) and applies the extra formats
diff --git a/src/plugins/texteditor/tabsettings.cpp b/src/plugins/texteditor/tabsettings.cpp
index 733e06dc4d35ddc7070e48cec8a38c39bfe5a318..fbcce87e7a833ca1712bdf1c446e620d6a02ebb1 100644
--- a/src/plugins/texteditor/tabsettings.cpp
+++ b/src/plugins/texteditor/tabsettings.cpp
@@ -341,7 +341,6 @@ void TabSettings::reindentLine(QTextBlock block, int delta) const
 
     QTextCursor cursor(block);
     cursor.beginEditBlock();
-    cursor.movePosition(QTextCursor::StartOfBlock);
     cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, firstNonSpace(text));
     cursor.removeSelectedText();
     cursor.insertText(indentString);
diff --git a/src/shared/qbs b/src/shared/qbs
new file mode 160000
index 0000000000000000000000000000000000000000..35f153400efc3303ac9f9c54506c6bbc5bc5c988
--- /dev/null
+++ b/src/shared/qbs
@@ -0,0 +1 @@
+Subproject commit 35f153400efc3303ac9f9c54506c6bbc5bc5c988
diff --git a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp
index ff43c68e3bda0ad77627b4677eb9a9568c376f0c..168772f17d34330b388d96adb02cde87f0f6e995 100644
--- a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp
+++ b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp
@@ -81,15 +81,6 @@ static QString useKindToString(UseKind useKind)
 // The following two functions are "enhancements" for QCOMPARE().
 namespace QTest {
 
-bool operator==(const Use& lhs, const Use& rhs)
-{
-    return
-        lhs.line == rhs.line &&
-        lhs.column == rhs.column &&
-        lhs.length == rhs.length &&
-        lhs.kind == rhs.kind;
-}
-
 template<>
 char *toString(const Use &use)
 {
@@ -216,11 +207,11 @@ void tst_CheckSymbols::test_checksymbols_LocalUse()
 void tst_CheckSymbols::test_checksymbols_FieldUse()
 {
     const QByteArray source =
-        "struct F {\n"
+        "struct F {\n"          // 1
         "    int i;\n"
         "    F() { i = 0; }\n"
         "};\n"
-        "int f()\n"
+        "int f()\n"             // 5
         "{\n"
         "    F s;\n"
         "    s.i = 2;\n"
@@ -233,8 +224,9 @@ void tst_CheckSymbols::test_checksymbols_FieldUse()
         << Use(5, 5, 1, SemanticInfo::FunctionUse)
         << Use(7, 5, 1, SemanticInfo::TypeUse)
         << Use(7, 7, 1, SemanticInfo::LocalUse)
+        << Use(8, 5, 1, SemanticInfo::LocalUse)
         << Use(8, 7, 1, SemanticInfo::FieldUse)
-        << Use(8, 5, 1, SemanticInfo::LocalUse);
+           ;
 
     TestData::check(source, expectedUses);
 }
@@ -245,10 +237,11 @@ void tst_CheckSymbols::test_checksymbols_EnumerationUse()
         "enum E { Red, Green, Blue };\n"
         "E e = Red\n";
     const QList<Use> expectedUses = QList<Use>()
-        << Use(1, 22, 4, SemanticInfo::EnumerationUse)
-        << Use(1, 15, 5, SemanticInfo::EnumerationUse)
         << Use(1, 6, 1, SemanticInfo::TypeUse)
-        << Use(1, 10, 3, SemanticInfo::EnumerationUse);
+        << Use(1, 10, 3, SemanticInfo::EnumerationUse)
+        << Use(1, 15, 5, SemanticInfo::EnumerationUse)
+        << Use(1, 22, 4, SemanticInfo::EnumerationUse)
+           ;
 
     TestData::check(source, expectedUses);
 }
@@ -256,18 +249,18 @@ void tst_CheckSymbols::test_checksymbols_EnumerationUse()
 void tst_CheckSymbols::test_checksymbols_VirtualMethodUse()
 {
     const QByteArray source =
-        "class B {\n"
-        "    virtual isThere();\n"
-        "};\n"
-        "class D: public B {\n"
-        "    isThere();\n"
+        "class B {\n"                   // 1
+        "    virtual bool isThere();\n" // 2
+        "};\n"                          // 3
+        "class D: public B {\n"         // 4
+        "    bool isThere();\n"         // 5
         "};\n";
     const QList<Use> expectedUses = QList<Use>()
-        << Use(1, 7, 1, SemanticInfo::TypeUse)
-        << Use(2, 13, 7, SemanticInfo::VirtualMethodUse)
-        << Use(4, 17, 1, SemanticInfo::TypeUse)
-        << Use(4, 7, 1, SemanticInfo::TypeUse)
-        << Use(5, 5, 7, SemanticInfo::VirtualMethodUse);
+        << Use(1, 7, 1, SemanticInfo::TypeUse)              // B
+        << Use(2, 18, 7, SemanticInfo::VirtualMethodUse)    // isThere
+        << Use(4, 7, 1, SemanticInfo::TypeUse)              // D
+        << Use(4, 17, 1, SemanticInfo::TypeUse)             // B
+        << Use(5, 10, 7, SemanticInfo::VirtualMethodUse);   // isThere
 
     TestData::check(source, expectedUses);
 }
@@ -298,8 +291,9 @@ void tst_CheckSymbols::test_checksymbols_MacroUse()
         << Use(2, 11, 3, SemanticInfo::MacroUse);
     const QList<Use> expectedUses = QList<Use>()
         << Use(1, 9, 3, SemanticInfo::MacroUse)
+        << Use(2, 5, 1, SemanticInfo::FunctionUse)
         << Use(2, 11, 3, SemanticInfo::MacroUse)
-        << Use(2, 5, 1, SemanticInfo::FunctionUse);
+           ;
 
     TestData::check(source, expectedUses, macroUses);
 }
@@ -361,17 +355,17 @@ void tst_CheckSymbols::test_checksymbols_StaticUse()
             << Use(1, 8, 5, SemanticInfo::TypeUse)
             << Use(3, 16, 3, SemanticInfo::FieldUse)
             << Use(4, 12, 5, SemanticInfo::TypeUse)
-            << Use(6, 16, 5, SemanticInfo::FieldUse)
             << Use(6, 9, 5, SemanticInfo::TypeUse)
+            << Use(6, 16, 5, SemanticInfo::FieldUse)
             << Use(7, 14, 3, SemanticInfo::FunctionUse)
-            << Use(11, 12, 3, SemanticInfo::FieldUse)
             << Use(11, 5, 5, SemanticInfo::TypeUse)
-            << Use(13, 20, 3, SemanticInfo::FunctionUse)
+            << Use(11, 12, 3, SemanticInfo::FieldUse)
             << Use(13, 6, 5, SemanticInfo::TypeUse)
             << Use(13, 13, 5, SemanticInfo::TypeUse)
+            << Use(13, 20, 3, SemanticInfo::FunctionUse)
             << Use(15, 5, 3, SemanticInfo::FieldUse)
-            << Use(16, 12, 3, SemanticInfo::FieldUse)
             << Use(16, 5, 5, SemanticInfo::TypeUse)
+            << Use(16, 12, 3, SemanticInfo::FieldUse)
             << Use(17, 5, 5, SemanticInfo::FieldUse)
             << Use(17, 12, 3, SemanticInfo::FieldUse)
                ;
@@ -396,9 +390,9 @@ void tst_CheckSymbols::test_checksymbols_VariableHasTheSameNameAsEnumUse()
             ;
     const QList<Use> expectedUses = QList<Use>()
             << Use(1, 8, 3, SemanticInfo::TypeUse)
-            << Use(3, 19, 3, SemanticInfo::EnumerationUse)
-            << Use(3, 14, 3, SemanticInfo::EnumerationUse)
             << Use(3, 10, 1, SemanticInfo::TypeUse)
+            << Use(3, 14, 3, SemanticInfo::EnumerationUse)
+            << Use(3, 19, 3, SemanticInfo::EnumerationUse)
             << Use(6, 8, 3, SemanticInfo::TypeUse)
             << Use(8, 9, 3, SemanticInfo::FieldUse)
             << Use(9, 9, 3, SemanticInfo::FieldUse)
@@ -431,18 +425,18 @@ void tst_CheckSymbols::test_checksymbols_NestedClassOfEnclosingTemplateUse()
             << Use(1, 18, 3, SemanticInfo::FieldUse)
             << Use(3, 19, 1, SemanticInfo::TypeUse)
             << Use(4, 8, 5, SemanticInfo::TypeUse)
-            << Use(6, 23, 2, SemanticInfo::FieldUse)
             << Use(6, 12, 6, SemanticInfo::TypeUse)
-            << Use(6, 29, 6, SemanticInfo::FieldUse)
             << Use(6, 21, 1, SemanticInfo::TypeUse)
+            << Use(6, 23, 2, SemanticInfo::FieldUse)
+            << Use(6, 29, 6, SemanticInfo::FieldUse)
             << Use(9, 6, 3, SemanticInfo::FunctionUse)
+            << Use(11, 5, 5, SemanticInfo::TypeUse)
             << Use(11, 11, 3, SemanticInfo::TypeUse)
             << Use(11, 16, 4, SemanticInfo::LocalUse)
-            << Use(11, 5, 5, SemanticInfo::TypeUse)
-            << Use(12, 20, 3, SemanticInfo::FieldUse)
-            << Use(12, 17, 2, SemanticInfo::FieldUse)
-            << Use(12, 10, 6, SemanticInfo::FieldUse)
             << Use(12, 5, 4, SemanticInfo::LocalUse)
+            << Use(12, 10, 6, SemanticInfo::FieldUse)
+            << Use(12, 17, 2, SemanticInfo::FieldUse)
+            << Use(12, 20, 3, SemanticInfo::FieldUse)
             ;
 
     TestData::check(source, expectedUses);
diff --git a/tests/auto/cplusplus/lexer/tst_lexer.cpp b/tests/auto/cplusplus/lexer/tst_lexer.cpp
index 1f956337a57a418848a3f8ddf6a9af5232c2d380..993cfe9782c21b3d7701e0a122a320a15cbbe6af 100644
--- a/tests/auto/cplusplus/lexer/tst_lexer.cpp
+++ b/tests/auto/cplusplus/lexer/tst_lexer.cpp
@@ -33,6 +33,8 @@
 #include <Token.h>
 #include <SimpleLexer.h>
 
+Q_DECLARE_METATYPE(QList<unsigned>)
+
 //TESTED_COMPONENT=src/libs/cplusplus
 using namespace CPlusPlus;
 
diff --git a/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp b/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp
index 27266dcd17448c022b78eef97e2f92870cd96d74..e5b24de13116a70842f7e673b9fa6570e2b316f1 100644
--- a/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp
+++ b/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp
@@ -68,7 +68,7 @@ void tst_PluginSpec::read()
     QCOMPARE(spec.version, QString("1.0.1"));
     QCOMPARE(spec.compatVersion, QString("1.0.0"));
     QCOMPARE(spec.experimental, false);
-    QCOMPARE(spec.enabled, true);
+    QCOMPARE(spec.enabledInSettings, true);
     QCOMPARE(spec.vendor, QString("Digia Plc"));
     QCOMPARE(spec.copyright, QString("(C) 2013 Digia Plc"));
     QCOMPARE(spec.license, QString("This is a default license bla\nblubbblubb\nend of terms"));
@@ -185,7 +185,7 @@ void tst_PluginSpec::experimental()
     Internal::PluginSpecPrivate spec(0);
     QVERIFY(spec.read("testspecs/simplespec_experimental.xml"));
     QCOMPARE(spec.experimental, true);
-    QCOMPARE(spec.enabled, false);
+    QCOMPARE(spec.enabledInSettings, false);
 }
 
 void tst_PluginSpec::locationAndPath()
diff --git a/tests/system/README b/tests/system/README
index f6e0311aa3dd2d5ca16fd53650ad279b4807cc45..7564980161753d4cbc9a032cf5e5772a15b91ca6 100644
--- a/tests/system/README
+++ b/tests/system/README
@@ -3,7 +3,7 @@ Prerequisites - general information
 Squish tests inside this folder have several prerequisites to get them running.
 
 First - and most important - you have to own a valid Squish license.
-Actually it's recommended to use Squish 4.2.2 - but 4.1.1 should be capable of running all tests.
+Actually it's recommended to use Squish 4.2.3 - but 4.1.1 should be capable of running all tests.
 For Squish on Mac it's necessary to change the used Python version to 2.6 inside the <SQUISHDIR>/etc/paths.ini
 
 Second - some of the test suites/test cases expect an installed QtSDK in its default location.
diff --git a/tests/system/shared/hook_utils.py b/tests/system/shared/hook_utils.py
index 7221be658661c78c97df406e2a71ba6dd0a71034..4a179eeee3dcdfc2d1110adb05efed339acb7214 100644
--- a/tests/system/shared/hook_utils.py
+++ b/tests/system/shared/hook_utils.py
@@ -1,6 +1,4 @@
 import re
-# flag that caches the information whether Windows firewall is running or not
-fireWallState = None
 
 # this function modifies all necessary run settings to make it possible to hook into
 # the application compiled by Creator
@@ -106,32 +104,43 @@ def modifyRunSettingsForHookIntoQtQuickUI(kitCount, workingDir, projectName, por
                               "window=':Qt Creator_Core::Internal::MainWindow' "
                               "leftWidget={type='QLabel' text~='Us(e|ing) <b>Build Environment</b>'"
                               " unnamed='1' visible='1'}}"))
-    row = 0
     for varName in ("PATH", "SQUISH_LIBQTDIR"):
-        __addVariableToRunEnvironment__(varName, qtLibPath, row)
-        row = row + 1
+        __addVariableToRunEnvironment__(varName, qtLibPath)
     if not platform.system() in ('Microsoft', 'Windows', 'Darwin'):
-        __addVariableToRunEnvironment__("LD_LIBRARY_PATH", qtLibPath, 0)
+        __addVariableToRunEnvironment__("LD_LIBRARY_PATH", qtLibPath)
     if platform.system() == "Darwin":
-        __addVariableToRunEnvironment__("DYLD_FRAMEWORK_PATH", qtLibPath, 0)
+        __addVariableToRunEnvironment__("DYLD_FRAMEWORK_PATH", qtLibPath)
     if not platform.system() in ('Microsoft', 'Windows'):
-        __addVariableToRunEnvironment__("DISPLAY", ":0.0", 0)
+        __addVariableToRunEnvironment__("DISPLAY", ":0.0")
     result = qmlViewer
     switchViewTo(ViewConstants.EDIT)
     return result
 
 # this helper method must be called on the run settings page of a Qt Quick UI with DetailsWidget
 # for the run settings already opened - it won't work on other views because of a different layout
-def __addVariableToRunEnvironment__(name, value, row):
+def __addVariableToRunEnvironment__(name, value):
     clickButton(waitForObject("{text='Add' type='QPushButton' unnamed='1' visible='1' "
                               "container={window=':Qt Creator_Core::Internal::MainWindow' "
                               "type='Utils::DetailsWidget' unnamed='1' visible='1' occurrence='2'}}"))
     varNameLineEd = waitForObject("{type='QExpandingLineEdit' visible='1' unnamed='1'}")
     replaceEditorContent(varNameLineEd, name)
+    type(varNameLineEd, "<Return>")
+    row = getTableRowOf(name, ":Qt Creator_QTableView")
+    if row == -1:
+        test.fatal("Could not find entered variable name inside table - skipping entering value.")
+        return
     valueLineEd = __doubleClickQTableView__(":Qt Creator_QTableView", row, 1)
     replaceEditorContent(valueLineEd, value)
     type(valueLineEd, "<Return>")
 
+def getTableRowOf(value, table):
+    tblModel = waitForObject(table).model()
+    items = dumpItems(tblModel)
+    if value in items:
+        return items.index(value)
+    else:
+        return -1
+
 def __getMkspecFromQMakeConf__(qmakeConf):
     if qmakeConf==None or not os.path.exists(qmakeConf):
         return None
@@ -286,7 +295,7 @@ def deleteAppFromWinFW(workingDir, projectName, isReleaseBuild=True):
     if result == 0:
         test.log("Deleted %s from firewall" % projectName)
     else:
-        test.fatal("Could not delete %s as allowed program from win firewall" % (projectName))
+        test.warning("Could not delete %s as allowed program from win firewall" % (projectName))
 
 # helper that can modify the win firewall to allow a program to communicate through it or delete it
 # param addToFW defines whether to add (True) or delete (False) this programm to/from the firewall
@@ -305,22 +314,22 @@ def __configureFW__(workingDir, projectName, isReleaseBuild, addToFW=True):
     else:
         mode = "delete"
         enable = ""
+        projectName = ""
     return subprocess.call('netsh firewall %s allowedprogram "%s.exe" %s %s' % (mode, path, projectName, enable))
 
 # helper to check whether win firewall is running or not
 # this doesn't check for other firewalls!
 def __isWinFirewallRunning__():
-    global fireWallState
-    if fireWallState != None:
-        return fireWallState
+    if hasattr(__isWinFirewallRunning__, "fireWallState"):
+        return __isWinFirewallRunning__.fireWallState
     if not platform.system() in ('Microsoft' 'Windows'):
-        fireWallState = False
+        __isWinFirewallRunning__.fireWallState = False
         return False
     result = getOutputFromCmdline("netsh firewall show state")
     for line in result.splitlines():
         if "Operational mode" in line:
-            fireWallState = not "Disable" in line
-            return fireWallState
+            __isWinFirewallRunning__.fireWallState = not "Disable" in line
+            return __isWinFirewallRunning__.fireWallState
     return None
 
 # this function adds the given executable as an attachable AUT
diff --git a/tests/system/shared/project.py b/tests/system/shared/project.py
index 7cfc3c145e7ec108b07aa28cd51724289f88337c..55c54b8ca32dc4b7fa2906ee53a6d5e85d312765 100644
--- a/tests/system/shared/project.py
+++ b/tests/system/shared/project.py
@@ -386,8 +386,33 @@ def __closeSubprocessByHookingInto__(executable, port, function, sType, userDefT
     try:
         attachToApplication(executable)
     except:
-        test.warning("Could not attach to '%s' - using fallback of pushing STOP inside Creator." % executable)
         resetApplicationContextToCreator()
+        if "Loading Qt Wrapper failed" in str(output.plainText):
+            test.warning("Loading of Qt Wrapper failed - probably different Qt versions.",
+                         "Resetting hook-into settings to continue.")
+            # assuming we're still on the build settings of the current project (TODO)
+            switchViewTo(ViewConstants.PROJECTS)
+            if sType == SubprocessType.QT_QUICK_UI:
+                selectConfig = "QML Viewer"
+            else:
+                selectConfig = executable
+            selectFromCombo(waitForObject("{buddy={text='Run configuration:' type='QLabel' "
+                                          "unnamed='1' visible='1'} type='QComboBox' unnamed='1' "
+                                          "visible='1'}"), selectConfig)
+            switchViewTo(ViewConstants.EDIT)
+            global processStarted
+            processStarted = False
+            runButton = waitForObject("{type='Core::Internal::FancyToolButton' text='Run' "
+                                      "visible='1'}")
+            clickButton(runButton)
+            if not waitFor("processStarted == True", 10000):
+                test.fatal("Something seems to be really wrong.", "Application output:"
+                           % str(output.plainText))
+                return False
+            else:
+                test.log("Application seems to be started without hooking-into.")
+        else:
+            test.warning("Could not attach to '%s' - using fallback of pushing STOP inside Creator." % executable)
         __closeSubprocessByPushingStop__(sType)
         return False
     if function == None:
diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py
index b8601407652a1b62bb815ad6d0348ed5d6c55a8a..0ed88890bb2aae78cbc907c73bb770f6edfda86b 100644
--- a/tests/system/shared/utils.py
+++ b/tests/system/shared/utils.py
@@ -212,7 +212,7 @@ def getOutputFromCmdline(cmdline):
     versCall.stdout.close()
     return result
 
-def selectFromFileDialog(fileName):
+def selectFromFileDialog(fileName, waitForFile=False):
     if platform.system() == "Darwin":
         snooze(1)
         nativeType("<Command+Shift+g>")
@@ -233,6 +233,10 @@ def selectFromFileDialog(fileName):
         waitFor("str(pathLine.text)==''")
         replaceEditorContent(pathLine, fName)
         clickButton(findObject("{text='Open' type='QPushButton'}"))
+    if waitForFile:
+        fileCombo = waitForObject(":Qt Creator_FilenameQComboBox")
+        if not waitFor("str(fileCombo.currentText) in fileName", 5000):
+            test.fail("%s could not be opened in time." % fileName)
 
 # add qt.qch from SDK path
 def addHelpDocumentationFromSDK():
diff --git a/tests/system/suite_editors/tst_select_all/test.py b/tests/system/suite_editors/tst_select_all/test.py
index b1f29259e07d2ffb5ed995146c5b24711595ff64..045adfe15bde95d472517fdda6abc141bc0c6c78 100644
--- a/tests/system/suite_editors/tst_select_all/test.py
+++ b/tests/system/suite_editors/tst_select_all/test.py
@@ -23,7 +23,7 @@ def main():
         test.log("Opening file %s" % currentFile)
         size = charactersInFile(currentFile)
         invokeMenuItem("File", "Open File or Project...")
-        selectFromFileDialog(currentFile)
+        selectFromFileDialog(currentFile, True)
         editor = getEditorForFileSuffix(currentFile)
         if editor == None:
             test.fatal("Could not get the editor for '%s'" % currentFile,