OSDN Git Service

QmlJS: Fix plugin dumpers running all the time if dump fails.
authorChristian Kamm <christian.d.kamm@nokia.com>
Thu, 14 Oct 2010 12:44:50 +0000 (14:44 +0200)
committerChristian Kamm <christian.d.kamm@nokia.com>
Thu, 14 Oct 2010 13:15:44 +0000 (15:15 +0200)
Task-number: QTCREATORBUG-2733
Reviewed-by: Kai Koehne
src/libs/qmljs/qmljsdocument.cpp
src/libs/qmljs/qmljsdocument.h
src/plugins/qmljseditor/qmljsmodelmanager.cpp

index 7537947..dfc3025 100644 (file)
@@ -358,6 +358,7 @@ LibraryInfo::LibraryInfo(const QmlDirParser &parser)
     : _valid(true)
     , _components(parser.components())
     , _plugins(parser.plugins())
+    , _dumped(false)
 {
 }
 
index d4810e9..1424961 100644 (file)
@@ -122,6 +122,7 @@ class QMLJS_EXPORT LibraryInfo
     QList<QmlDirParser::Plugin> _plugins;
     typedef QList<const Interpreter::FakeMetaObject *> FakeMetaObjectList;
     FakeMetaObjectList _metaObjects;
+    bool _dumped;
 
 public:
     LibraryInfo();
@@ -142,6 +143,12 @@ public:
 
     bool isValid() const
     { return _valid; }
+
+    bool isDumped() const
+    { return _dumped; }
+
+    void setDumped(bool dumped)
+    { _dumped = dumped; }
 };
 
 class QMLJS_EXPORT Snapshot
index f30357f..379431f 100644 (file)
@@ -472,6 +472,8 @@ void ModelManager::onLoadPluginTypes(const QString &libraryPath, const QString &
     const QString canonicalLibraryPath = QDir::cleanPath(libraryPath);
     if (m_runningQmldumps.values().contains(canonicalLibraryPath))
         return;
+    if (_snapshot.libraryInfo(canonicalLibraryPath).isDumped())
+        return;
 
     ProjectExplorer::Project *activeProject = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject();
     if (!activeProject)
@@ -526,36 +528,33 @@ void ModelManager::qmlPluginTypeDumpDone(int exitCode)
     process->deleteLater();
 
     const QString libraryPath = m_runningQmldumps.take(process);
+    LibraryInfo libraryInfo = _snapshot.libraryInfo(libraryPath);
+    libraryInfo.setDumped(true);
 
     if (exitCode != 0) {
         Core::MessageManager *messageManager = Core::MessageManager::instance();
         messageManager->printToOutputPane(qmldumpErrorMessage(libraryPath, process->readAllStandardError()));
-        return;
     }
 
     const QByteArray output = process->readAllStandardOutput();
     QMap<QString, Interpreter::FakeMetaObject *> newObjects;
     const QString error = Interpreter::CppQmlTypesLoader::parseQmlTypeXml(output, &newObjects);
-    if (!error.isEmpty())
-        return;
-
-    // convert from QList<T *> to QList<const T *>
-    QList<const Interpreter::FakeMetaObject *> objectsList;
-    QMapIterator<QString, Interpreter::FakeMetaObject *> it(newObjects);
-    while (it.hasNext()) {
-        it.next();
-        objectsList.append(it.value());
-    }
-
-    QMutexLocker locker(&m_mutex);
 
-    if (!libraryPath.isEmpty()) {
-        LibraryInfo libraryInfo = _snapshot.libraryInfo(libraryPath);
+    if (exitCode == 0 && error.isEmpty()) {
+        // convert from QList<T *> to QList<const T *>
+        QList<const Interpreter::FakeMetaObject *> objectsList;
+        QMapIterator<QString, Interpreter::FakeMetaObject *> it(newObjects);
+        while (it.hasNext()) {
+            it.next();
+            objectsList.append(it.value());
+        }
         libraryInfo.setMetaObjects(objectsList);
-        _snapshot.insertLibraryInfo(libraryPath, libraryInfo);
-    } else {
-        Interpreter::CppQmlTypesLoader::builtinObjects.append(objectsList);
+        if (libraryPath.isEmpty())
+            Interpreter::CppQmlTypesLoader::builtinObjects.append(objectsList);
     }
+
+    if (!libraryPath.isEmpty())
+        emitLibraryInfoUpdated(libraryPath, libraryInfo);
 }
 
 void ModelManager::qmlPluginTypeDumpError(QProcess::ProcessError)
@@ -569,4 +568,10 @@ void ModelManager::qmlPluginTypeDumpError(QProcess::ProcessError)
 
     Core::MessageManager *messageManager = Core::MessageManager::instance();
     messageManager->printToOutputPane(qmldumpErrorMessage(libraryPath, process->readAllStandardError()));
+
+    if (!libraryPath.isEmpty()) {
+        LibraryInfo libraryInfo = _snapshot.libraryInfo(libraryPath);
+        libraryInfo.setDumped(true);
+        emitLibraryInfoUpdated(libraryPath, libraryInfo);
+    }
 }