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

@@ -1944,7 +1944,6 @@ const Value *Function::invoke(const Activation *activation) const
////////////////////////////////////////////////////////////////////////////////
QList<FakeMetaObject::ConstPtr> CppQmlTypesLoader::builtinObjects;
QList<FakeMetaObject::ConstPtr> CppQmlTypesLoader::cppObjects;
QStringList CppQmlTypesLoader::load(const QFileInfoList &xmlFiles)
{
@@ -2438,7 +2437,6 @@ Engine::Engine()
initializePrototypes();
_cppQmlTypes.load(this, CppQmlTypesLoader::builtinObjects);
_cppQmlTypes.load(this, CppQmlTypesLoader::cppObjects);
// the 'Qt' object is dumped even though it is not exported
// it contains useful information, in particular on enums - add the

View File

@@ -587,7 +587,6 @@ public:
/** \return an empty list when successful, error messages otherwise. */
static QStringList load(const QFileInfoList &xmlFiles);
static QList<LanguageUtils::FakeMetaObject::ConstPtr> builtinObjects;
static QList<LanguageUtils::FakeMetaObject::ConstPtr> cppObjects;
// parses the xml string and fills the newObjects map
static QString parseQmlTypeXml(const QByteArray &xml,

View File

@@ -120,6 +120,14 @@ Link::Link(Context *context, const Document::Ptr &doc, const Snapshot &snapshot,
d->snapshot = snapshot;
d->importPaths = importPaths;
// populate engine with types from C++
ModelManagerInterface *modelManager = ModelManagerInterface::instance();
if (modelManager) {
foreach (const QList<FakeMetaObject::ConstPtr> &cppTypes, modelManager->cppQmlTypes()) {
engine()->cppQmlTypes().load(engine(), cppTypes);
}
}
linkImports();
}

View File

@@ -110,6 +110,8 @@ public:
Table _elements;
};
typedef QHash<QString, QList<LanguageUtils::FakeMetaObject::ConstPtr> > CppQmlTypeHash;
public:
ModelManagerInterface(QObject *parent = 0);
virtual ~ModelManagerInterface();
@@ -132,6 +134,8 @@ public:
virtual void loadPluginTypes(const QString &libraryPath, const QString &importPath, const QString &importUri) = 0;
virtual CppQmlTypeHash cppQmlTypes() const = 0;
signals:
void documentUpdated(QmlJS::Document::Ptr doc);
void documentChangedOnDisk(QmlJS::Document::Ptr doc);