forked from qt-creator/qt-creator
QmlJS: Switch to new format for QML meta data.
This commit is contained in:
@@ -96,8 +96,8 @@ void PluginDumper::onLoadPluginTypes(const QString &libraryPath, const QString &
|
||||
}
|
||||
|
||||
// watch library xml file
|
||||
if (plugin.hasPredumpedXmlFile()) {
|
||||
const QString &path = plugin.predumpedXmlFilePath();
|
||||
if (plugin.hasPredumpedQmlTypesFile()) {
|
||||
const QString &path = plugin.predumpedQmlTypesFilePath();
|
||||
m_pluginWatcher->addFile(path);
|
||||
m_libraryToPluginIndex.insert(path, index);
|
||||
}
|
||||
@@ -134,15 +134,15 @@ static QString qmldumpFailedMessage(const QString &error)
|
||||
).arg(firstLines);
|
||||
}
|
||||
|
||||
static QList<FakeMetaObject::ConstPtr> parseHelper(const QByteArray &xml, QString *error)
|
||||
static QList<FakeMetaObject::ConstPtr> parseHelper(const QByteArray &qmlTypeDescriptions, QString *error)
|
||||
{
|
||||
QList<FakeMetaObject::ConstPtr> ret;
|
||||
QMap<QString, FakeMetaObject::Ptr> newObjects;
|
||||
*error = Interpreter::CppQmlTypesLoader::parseQmlTypeXml(xml, &newObjects);
|
||||
QHash<QString, FakeMetaObject::Ptr> newObjects;
|
||||
*error = Interpreter::CppQmlTypesLoader::parseQmlTypeDescriptions(qmlTypeDescriptions, &newObjects);
|
||||
|
||||
if (error->isEmpty()) {
|
||||
// convert from QList<T *> to QList<const T *>
|
||||
QMapIterator<QString, FakeMetaObject::Ptr> it(newObjects);
|
||||
QHashIterator<QString, FakeMetaObject::Ptr> it(newObjects);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
ret.append(it.value());
|
||||
@@ -178,8 +178,9 @@ void PluginDumper::qmlPluginTypeDumpDone(int exitCode)
|
||||
|
||||
if (exitCode == 0 && error.isEmpty()) {
|
||||
libraryInfo.setMetaObjects(objectsList);
|
||||
if (libraryPath.isEmpty())
|
||||
Interpreter::CppQmlTypesLoader::builtinObjects.append(objectsList);
|
||||
// ### disabled code path for running qmldump to get Qt's builtins
|
||||
// if (libraryPath.isEmpty())
|
||||
// Interpreter::CppQmlTypesLoader::builtinObjects.append(objectsList);
|
||||
libraryInfo.setDumpStatus(LibraryInfo::DumpDone);
|
||||
}
|
||||
|
||||
@@ -220,26 +221,26 @@ void PluginDumper::pluginChanged(const QString &pluginLibrary)
|
||||
|
||||
void PluginDumper::dump(const Plugin &plugin)
|
||||
{
|
||||
if (plugin.hasPredumpedXmlFile()) {
|
||||
if (plugin.hasPredumpedQmlTypesFile()) {
|
||||
const Snapshot snapshot = m_modelManager->snapshot();
|
||||
LibraryInfo libraryInfo = snapshot.libraryInfo(plugin.qmldirPath);
|
||||
if (!libraryInfo.isValid())
|
||||
return;
|
||||
|
||||
const QString &path = plugin.predumpedXmlFilePath();
|
||||
QFile libraryXmlFile(path);
|
||||
if (!libraryXmlFile.open(QFile::ReadOnly | QFile::Text)) {
|
||||
const QString &path = plugin.predumpedQmlTypesFilePath();
|
||||
QFile libraryQmlTypesFile(path);
|
||||
if (!libraryQmlTypesFile.open(QFile::ReadOnly | QFile::Text)) {
|
||||
libraryInfo.setDumpStatus(LibraryInfo::DumpError,
|
||||
tr("Could not open file '%1' for reading.").arg(path));
|
||||
m_modelManager->updateLibraryInfo(plugin.qmldirPath, libraryInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
const QByteArray xml = libraryXmlFile.readAll();
|
||||
libraryXmlFile.close();
|
||||
const QByteArray qmlTypeDescriptions = libraryQmlTypesFile.readAll();
|
||||
libraryQmlTypesFile.close();
|
||||
|
||||
QString error;
|
||||
const QList<FakeMetaObject::ConstPtr> objectsList = parseHelper(xml, &error);
|
||||
const QList<FakeMetaObject::ConstPtr> objectsList = parseHelper(qmlTypeDescriptions, &error);
|
||||
|
||||
if (error.isEmpty()) {
|
||||
libraryInfo.setMetaObjects(objectsList);
|
||||
@@ -390,12 +391,12 @@ QString PluginDumper::resolvePlugin(const QDir &qmldirPath, const QString &qmldi
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PluginDumper::Plugin::hasPredumpedXmlFile() const
|
||||
bool PluginDumper::Plugin::hasPredumpedQmlTypesFile() const
|
||||
{
|
||||
return QFileInfo(predumpedXmlFilePath()).isFile();
|
||||
return QFileInfo(predumpedQmlTypesFilePath()).isFile();
|
||||
}
|
||||
|
||||
QString PluginDumper::Plugin::predumpedXmlFilePath() const
|
||||
QString PluginDumper::Plugin::predumpedQmlTypesFilePath() const
|
||||
{
|
||||
return QString("%1%2library.xml").arg(qmldirPath, QDir::separator());
|
||||
return QString("%1%2plugins.qmltypes").arg(qmldirPath, QDir::separator());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user