diff --git a/src/libs/qmljs/qmljsdocument.cpp b/src/libs/qmljs/qmljsdocument.cpp
index 0eceac0ca94f2e097c3a44cf03d4b26c34709378..897c56a891333469976ffcb85e4943f2c6a21c65 100644
--- a/src/libs/qmljs/qmljsdocument.cpp
+++ b/src/libs/qmljs/qmljsdocument.cpp
@@ -389,9 +389,9 @@ Snapshot::~Snapshot()
 {
 }
 
-void Snapshot::insert(const Document::Ptr &document)
+void Snapshot::insert(const Document::Ptr &document, bool allowInvalid)
 {
-    if (document && (document->qmlProgram() || document->jsProgram())) {
+    if (document && (allowInvalid || document->qmlProgram() || document->jsProgram())) {
         const QString fileName = document->fileName();
         const QString path = document->path();
 
diff --git a/src/libs/qmljs/qmljsdocument.h b/src/libs/qmljs/qmljsdocument.h
index 0999712faaf3949c126886b3863249d8be803688..9b6191d8fa125c4f7248ebaff63f5f43ce1e6f61 100644
--- a/src/libs/qmljs/qmljsdocument.h
+++ b/src/libs/qmljs/qmljsdocument.h
@@ -198,7 +198,7 @@ public:
     const_iterator begin() const { return _documents.begin(); }
     const_iterator end() const { return _documents.end(); }
 
-    void insert(const Document::Ptr &document);
+    void insert(const Document::Ptr &document, bool allowInvalid = false);
     void insertLibraryInfo(const QString &path, const LibraryInfo &info);
     void remove(const QString &fileName);
 
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.h b/src/libs/qmljs/qmljsmodelmanagerinterface.h
index 731b9c6ade712eaa747d163ee08b7dd3d5365386..17530e435936c6a9f5ba3f97e59f9032632b1fc6 100644
--- a/src/libs/qmljs/qmljsmodelmanagerinterface.h
+++ b/src/libs/qmljs/qmljsmodelmanagerinterface.h
@@ -119,7 +119,7 @@ public:
     static ModelManagerInterface *instance();
 
     virtual WorkingCopy workingCopy() const = 0;
-    virtual QmlJS::Snapshot snapshot() const = 0;
+    virtual QmlJS::Snapshot snapshot(bool preferValid = true) const = 0;
 
     virtual void updateSourceFiles(const QStringList &files,
                                    bool emitDocumentOnDiskChanged) = 0;
diff --git a/src/plugins/qmljseditor/qmltaskmanager.cpp b/src/plugins/qmljseditor/qmltaskmanager.cpp
index f87ae0ae60ad7a53ff7734509e39f7fa37094446..93e17201cfd888fec64db883caf7747ce524fa40 100644
--- a/src/plugins/qmljseditor/qmltaskmanager.cpp
+++ b/src/plugins/qmljseditor/qmltaskmanager.cpp
@@ -119,7 +119,8 @@ void QmlTaskManager::collectMessages(
                                                fileName, Constants::TASK_CATEGORY_QML_ANALYSIS);
             }
 
-            future.reportResult(result);
+            if (!result.tasks.isEmpty())
+                future.reportResult(result);
             if (future.isCanceled())
                 break;
         }
@@ -145,16 +146,15 @@ void QmlTaskManager::updateMessagesNow(bool updateSemantic)
 
     // abort any update that's going on already
     m_messageCollector.cancel();
-    removeAllTasks();
+    removeAllTasks(updateSemantic);
 
-    // collect all the source files in open projects
     ModelManagerInterface *modelManager = ModelManagerInterface::instance();
 
     // process them
     QFuture<FileErrorMessages> future =
             QtConcurrent::run<FileErrorMessages>(
-                &collectMessages, modelManager->snapshot(), modelManager->projectInfos(),
-                modelManager->importPaths(), !updateSemantic);
+                &collectMessages, modelManager->snapshot(false), modelManager->projectInfos(),
+                modelManager->importPaths(), updateSemantic);
     m_messageCollector.setFuture(future);
 }
 
@@ -198,14 +198,11 @@ void QmlTaskManager::removeTasksForFile(const QString &fileName)
     }
 }
 
-void QmlTaskManager::removeAllTasks()
+void QmlTaskManager::removeAllTasks(bool clearSemantic)
 {
-    QMapIterator<QString, QList<ProjectExplorer::Task> > it(m_docsWithTasks);
-    while (it.hasNext()) {
-        it.next();
-        foreach (const ProjectExplorer::Task &task, it.value())
-            m_taskHub->removeTask(task);
-    }
+    m_taskHub->clearTasks(Constants::TASK_CATEGORY_QML);
+    if (clearSemantic)
+        m_taskHub->clearTasks(Constants::TASK_CATEGORY_QML_ANALYSIS);
     m_docsWithTasks.clear();
 }
 
diff --git a/src/plugins/qmljseditor/qmltaskmanager.h b/src/plugins/qmljseditor/qmltaskmanager.h
index 354ca14c72280298886990bc54705a22940446ab..8657228d085559c9b0a2a6a3be840d40b90dfb81 100644
--- a/src/plugins/qmljseditor/qmltaskmanager.h
+++ b/src/plugins/qmljseditor/qmltaskmanager.h
@@ -76,7 +76,7 @@ private slots:
 private:
     void insertTask(const ProjectExplorer::Task &task);
     void removeTasksForFile(const QString &fileName);
-    void removeAllTasks();
+    void removeAllTasks(bool clearSemantic);
 
 private:
     class FileErrorMessages
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp
index 6ec07db623fc68194163a5617a2c3e03d1e99703..6ff2c895504db617d2f96401093dfa39a62a1fba 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.cpp
+++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp
@@ -169,11 +169,14 @@ ModelManagerInterface::WorkingCopy ModelManager::workingCopy() const
     return workingCopy;
 }
 
-Snapshot ModelManager::snapshot() const
+Snapshot ModelManager::snapshot(bool preferValid) const
 {
     QMutexLocker locker(&m_mutex);
 
-    return _snapshot;
+    if (preferValid)
+        return _validSnapshot;
+    else
+        return _newestSnapshot;
 }
 
 void ModelManager::updateSourceFiles(const QStringList &files,
@@ -228,8 +231,10 @@ void ModelManager::removeFiles(const QStringList &files)
 
     QMutexLocker locker(&m_mutex);
 
-    foreach (const QString &file, files)
-        _snapshot.remove(file);
+    foreach (const QString &file, files) {
+        _validSnapshot.remove(file);
+        _newestSnapshot.remove(file);
+    }
 }
 
 QList<ModelManager::ProjectInfo> ModelManager::projectInfos() const
@@ -257,7 +262,7 @@ void ModelManager::updateProjectInfo(const ProjectInfo &pinfo)
         QMutexLocker locker(&m_mutex);
         oldInfo = m_projects.value(pinfo.project);
         m_projects.insert(pinfo.project, pinfo);
-        snapshot = _snapshot;
+        snapshot = _validSnapshot;
     }
 
     if (oldInfo.qmlDumpPath != pinfo.qmlDumpPath
@@ -302,7 +307,8 @@ void ModelManager::updateDocument(Document::Ptr doc)
 {
     {
         QMutexLocker locker(&m_mutex);
-        _snapshot.insert(doc);
+        _validSnapshot.insert(doc);
+        _newestSnapshot.insert(doc, true);
     }
     emit documentUpdated(doc);
 }
@@ -311,7 +317,8 @@ void ModelManager::updateLibraryInfo(const QString &path, const LibraryInfo &inf
 {
     {
         QMutexLocker locker(&m_mutex);
-        _snapshot.insertLibraryInfo(path, info);
+        _validSnapshot.insertLibraryInfo(path, info);
+        _newestSnapshot.insertLibraryInfo(path, info);
     }
     // only emit if we got new useful information
     if (info.isValid())
@@ -650,7 +657,7 @@ void ModelManager::updateImportPaths()
     m_allImportPaths.removeDuplicates();
 
     // check if any file in the snapshot imports something new in the new paths
-    Snapshot snapshot = _snapshot;
+    Snapshot snapshot = _validSnapshot;
     QStringList importedFiles;
     QSet<QString> scannedPaths;
     QSet<QString> newLibraries;
@@ -724,7 +731,7 @@ LibraryInfo ModelManager::builtins(const Document::Ptr &doc) const
     if (!info.isValid())
         return LibraryInfo();
 
-    return _snapshot.libraryInfo(info.qtImportsPath);
+    return _validSnapshot.libraryInfo(info.qtImportsPath);
 }
 
 void ModelManager::joinAllThreads()
@@ -741,11 +748,12 @@ void ModelManager::resetCodeModel()
         QMutexLocker locker(&m_mutex);
 
         // find all documents currently in the code model
-        foreach (Document::Ptr doc, _snapshot)
+        foreach (Document::Ptr doc, _validSnapshot)
             documents.append(doc->fileName());
 
         // reset the snapshot
-        _snapshot = Snapshot();
+        _validSnapshot = Snapshot();
+        _newestSnapshot = Snapshot();
     }
 
     // start a reparse thread
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.h b/src/plugins/qmljstools/qmljsmodelmanager.h
index 14e51b95d011060f83efeca5c3fbbc984fb5a278..7fe82145b38ece814314dc28e1cd2dd6a0bf01be 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.h
+++ b/src/plugins/qmljstools/qmljsmodelmanager.h
@@ -69,7 +69,7 @@ public:
     void delayedInitialization();
 
     virtual WorkingCopy workingCopy() const;
-    virtual QmlJS::Snapshot snapshot() const;
+    virtual QmlJS::Snapshot snapshot(bool preferValid = true) const;
 
     virtual void updateSourceFiles(const QStringList &files,
                                    bool emitDocumentOnDiskChanged);
@@ -126,7 +126,8 @@ private:
 
     mutable QMutex m_mutex;
     Core::ICore *m_core;
-    QmlJS::Snapshot _snapshot;
+    QmlJS::Snapshot _validSnapshot;
+    QmlJS::Snapshot _newestSnapshot;
     QStringList m_allImportPaths;
     QStringList m_defaultImportPaths;