diff --git a/src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.h b/src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.h
index 13188dd8180c74a41f0a2aaa8f3f0c9413fdc797..0e2261a8023f8f54e2d2b4419695b226529399db 100644
--- a/src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.h
+++ b/src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.h
@@ -42,6 +42,7 @@ class CMakeProject;
 
 class CMakeUiCodeModelSupport : public CppTools::UiCodeModelSupport
 {
+    Q_OBJECT
 public:
     CMakeUiCodeModelSupport(CPlusPlus::CppModelManagerInterface *modelmanager,
                           CMakeProject *project,
diff --git a/src/plugins/cpptools/abstracteditorsupport.h b/src/plugins/cpptools/abstracteditorsupport.h
index e52eebf319e1927257229786d65981e6e0d82ebc..858f893cb828ed5ffbf7e3706e21cdbeb32d531a 100644
--- a/src/plugins/cpptools/abstracteditorsupport.h
+++ b/src/plugins/cpptools/abstracteditorsupport.h
@@ -33,6 +33,7 @@
 #include "cpptools_global.h"
 
 #include <QString>
+#include <QObject>
 
 namespace CPlusPlus {
 class CppModelManagerInterface;
@@ -40,8 +41,9 @@ class CppModelManagerInterface;
 
 namespace CppTools {
 
-class CPPTOOLS_EXPORT AbstractEditorSupport
+class CPPTOOLS_EXPORT AbstractEditorSupport : public QObject
 {
+    Q_OBJECT
 public:
     explicit AbstractEditorSupport(CPlusPlus::CppModelManagerInterface *modelmanager);
     virtual ~AbstractEditorSupport();
diff --git a/src/plugins/cpptools/uicodecompletionsupport.cpp b/src/plugins/cpptools/uicodecompletionsupport.cpp
index b9e2f7bdde55badc5e37ef0e9a8ee7e52670c2be..54403f9a93f08b3a54a1b885d9a5bcb3a52ed4c6 100644
--- a/src/plugins/cpptools/uicodecompletionsupport.cpp
+++ b/src/plugins/cpptools/uicodecompletionsupport.cpp
@@ -44,11 +44,12 @@ UiCodeModelSupport::UiCodeModelSupport(CppModelManagerInterface *modelmanager,
     : AbstractEditorSupport(modelmanager),
       m_sourceName(source),
       m_fileName(uiHeaderFile),
-      m_initialized(false),
-      m_running(false)
+      m_state(BARE)
 {
     if (debug)
         qDebug()<<"ctor UiCodeModelSupport for"<<m_sourceName<<uiHeaderFile;
+    connect(&m_process, SIGNAL(finished(int)),
+            this, SLOT(finishProcess()));
 }
 
 UiCodeModelSupport::~UiCodeModelSupport()
@@ -59,7 +60,8 @@ UiCodeModelSupport::~UiCodeModelSupport()
 
 void UiCodeModelSupport::init() const
 {
-    m_initialized = true;
+    if (m_state != BARE)
+        return;
     QDateTime sourceTime = QFileInfo(m_sourceName).lastModified();
     QFileInfo uiHeaderFileInfo(m_fileName);
     QDateTime uiHeaderTime = uiHeaderFileInfo.exists() ? uiHeaderFileInfo.lastModified() : QDateTime();
@@ -71,6 +73,7 @@ void UiCodeModelSupport::init() const
             QTextStream stream(&file);
             m_contents = stream.readAll().toUtf8();
             m_cacheTime = uiHeaderTime;
+            m_state = FINISHED;
             return;
         }
     }
@@ -91,20 +94,25 @@ void UiCodeModelSupport::init() const
                 qDebug()<<"uic run wasn't succesfull";
             m_cacheTime = QDateTime ();
             m_contents = QByteArray();
+            m_state = FINISHED;
             return;
         }
     } else {
         if (debug)
             qDebug()<<"Could open "<<m_sourceName<<"needed for the cpp model";
         m_contents = QByteArray();
+        m_state = FINISHED;
     }
 }
 
 QByteArray UiCodeModelSupport::contents() const
 {
-    if (!m_initialized)
+    // Check the common case first
+    if (m_state == FINISHED)
+        return m_contents;
+    if (m_state == BARE)
         init();
-    if (m_running)
+    if (m_state == RUNNING)
         finishProcess();
 
     return m_contents;
@@ -120,13 +128,16 @@ void UiCodeModelSupport::setFileName(const QString &name)
     if (m_fileName == name && m_cacheTime.isValid())
         return;
 
+    if (m_state == RUNNING)
+        finishProcess();
+
     if (debug)
         qDebug() << "UiCodeModelSupport::setFileName"<<name;
 
     m_fileName = name;
     m_contents.clear();
     m_cacheTime = QDateTime();
-    init();
+    m_state = BARE;
 }
 
 bool UiCodeModelSupport::runUic(const QString &ui) const
@@ -145,19 +156,23 @@ bool UiCodeModelSupport::runUic(const QString &ui) const
     if (!m_process.waitForBytesWritten(3000))
         goto error;
     m_process.closeWriteChannel();
-    m_running = true;
+    m_state = RUNNING;
     return true;
 
 error:
     if (debug)
         qDebug() << "failed" << m_process.readAllStandardError();
     m_process.kill();
-    m_running = false;
+    m_state = FINISHED;
     return false;
 }
 
 void UiCodeModelSupport::updateFromEditor(const QString &formEditorContents)
 {
+    if (m_state == BARE)
+        init();
+    if (m_state == RUNNING)
+        finishProcess();
     if (runUic(formEditorContents))
         if (finishProcess())
             updateDocument();
@@ -165,23 +180,29 @@ void UiCodeModelSupport::updateFromEditor(const QString &formEditorContents)
 
 bool UiCodeModelSupport::finishProcess() const
 {
-    if (!m_running)
+    if (m_state != RUNNING)
         return false;
     if (!m_process.waitForFinished(3000)
             && m_process.exitStatus() != QProcess::NormalExit
             && m_process.exitCode() != 0) {
+        if (m_state != RUNNING) // waitForFinished can recurse into finishProcess
+            return false;
+
         if (debug)
             qDebug() << "failed" << m_process.readAllStandardError();
         m_process.kill();
-        m_running = false;
+        m_state = FINISHED;
         return false;
     }
 
+    if (m_state != RUNNING) // waitForFinished can recurse into finishProcess
+        return true;
+
     m_contents = m_process.readAllStandardOutput();
     m_cacheTime = QDateTime::currentDateTime();
     if (debug)
         qDebug() << "ok" << m_contents.size() << "bytes.";
-    m_running = false;
+    m_state = FINISHED;
     return true;
 }
 
@@ -189,6 +210,10 @@ void UiCodeModelSupport::updateFromBuild()
 {
     if (debug)
         qDebug()<<"UiCodeModelSupport::updateFromBuild() for file"<<m_sourceName;
+    if (m_state == BARE)
+        init();
+    if (m_state == RUNNING)
+        finishProcess();
     // This is mostly a fall back for the cases when uic couldn't be run
     // it pays special attention to the case where a ui_*h was newly created
     QDateTime sourceTime = QFileInfo(m_sourceName).lastModified();
diff --git a/src/plugins/cpptools/uicodecompletionsupport.h b/src/plugins/cpptools/uicodecompletionsupport.h
index 5a1d8883de559110d207c2989b6d1283cb3ba4da..eb25bbef61654dc28275ac75d0bb61c1d884a654 100644
--- a/src/plugins/cpptools/uicodecompletionsupport.h
+++ b/src/plugins/cpptools/uicodecompletionsupport.h
@@ -43,6 +43,7 @@ namespace CppTools {
 
 class CPPTOOLS_EXPORT UiCodeModelSupport : public AbstractEditorSupport
 {
+    Q_OBJECT
 public:
     UiCodeModelSupport(CPlusPlus::CppModelManagerInterface *modelmanager,
                        const QString &sourceFile,
@@ -58,16 +59,18 @@ protected:
     virtual QString uicCommand() const = 0;
     virtual QStringList environment() const = 0;
 private:
+    enum State { BARE, RUNNING, FINISHED };
+
     void init() const;
     bool runUic(const QString &ui) const;
-    bool finishProcess() const;
+    Q_SLOT bool finishProcess() const;
     mutable QProcess m_process;
     QString m_sourceName;
     QString m_fileName;
-    mutable bool m_initialized;
+    mutable State m_state;
     mutable QByteArray m_contents;
     mutable QDateTime m_cacheTime;
-    mutable bool m_running;
+    static QList<UiCodeModelSupport *> m_waitingForStart;
 };
 
 } // CppTools
diff --git a/src/plugins/qt4projectmanager/qtuicodemodelsupport.h b/src/plugins/qt4projectmanager/qtuicodemodelsupport.h
index 7816da191d23b0ea651094766a95806020005e8b..d09e2f912655492d653256455ce27b25c61db0ba 100644
--- a/src/plugins/qt4projectmanager/qtuicodemodelsupport.h
+++ b/src/plugins/qt4projectmanager/qtuicodemodelsupport.h
@@ -42,6 +42,7 @@ namespace Internal {
 
 class Qt4UiCodeModelSupport : public CppTools::UiCodeModelSupport
 {
+    Q_OBJECT
 public:
     Qt4UiCodeModelSupport(CPlusPlus::CppModelManagerInterface *modelmanager,
                           Qt4Project *project,