Qml/C++: Fix performance problem with type extraction.

By moving the offending code into a background thread.

Reviewed-by: Erik Verbruggen
This commit is contained in:
Christian Kamm
2011-01-06 10:01:45 +01:00
parent c7070526ec
commit 283a3d32cd
9 changed files with 86 additions and 29 deletions

View File

@@ -38,6 +38,8 @@
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljs/qmljsdocument.h>
#include <cplusplus/CppDocument.h>
#include <cplusplus/ModelManagerInterface.h>
#include <QFuture>
#include <QFutureSynchronizer>
@@ -85,6 +87,8 @@ public:
virtual void loadPluginTypes(const QString &libraryPath, const QString &importPath, const QString &importUri);
virtual CppQmlTypeHash cppQmlTypes() const;
Q_SIGNALS:
void projectPathChanged(const QString &projectPath);
@@ -104,10 +108,12 @@ protected:
void updateImportPaths();
private slots:
void updateCppQmlTypes();
void queueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc);
void startCppQmlTypeUpdate();
private:
static bool matchesMimeType(const Core::MimeType &fileMimeType, const Core::MimeType &knownMimeType);
static void updateCppQmlTypes(ModelManager *qmlModelManager, CPlusPlus::CppModelManagerInterface *cppModelManager, QSet<QString> files);
mutable QMutex m_mutex;
Core::ICore *m_core;
@@ -116,7 +122,11 @@ private:
QStringList m_defaultImportPaths;
QFutureSynchronizer<void> m_synchronizer;
QTimer *m_updateCppQmlTypesTimer;
QSet<QString> m_queuedCppDocuments;
CppQmlTypeHash m_cppTypes;
mutable QMutex m_cppTypesMutex;
// project integration
QMap<ProjectExplorer::Project *, ProjectInfo> m_projects;