forked from qt-creator/qt-creator
qmldump: Fix dumping empty names for generated QMetaObjects.
Task-number: QTCREATORBUG-6543 Reviewed-by: Roberto Raggi Change-Id: I81af457eed14a2f863a0a92d4f5ff69c2dc48d67 Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
This commit is contained in:
@@ -141,6 +141,31 @@ QByteArray convertToId(const QByteArray &cppName)
|
|||||||
return cppToId.value(cppName, cppName);
|
return cppToId.value(cppName, cppName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray convertToId(const QMetaObject *mo)
|
||||||
|
{
|
||||||
|
QByteArray className(mo->className());
|
||||||
|
if (!className.isEmpty())
|
||||||
|
return convertToId(className);
|
||||||
|
|
||||||
|
// likely a metaobject generated for an extended qml object
|
||||||
|
if (mo->superClass()) {
|
||||||
|
className = convertToId(mo->superClass());
|
||||||
|
className.append("_extended");
|
||||||
|
return className;
|
||||||
|
}
|
||||||
|
|
||||||
|
static QHash<const QMetaObject *, QByteArray> generatedNames;
|
||||||
|
className = generatedNames.value(mo);
|
||||||
|
if (!className.isEmpty())
|
||||||
|
return className;
|
||||||
|
|
||||||
|
qWarning() << "Found a QMetaObject without a className, generating a random name";
|
||||||
|
className = QByteArray("error-unknown-name-");
|
||||||
|
className.append(QByteArray::number(generatedNames.size()));
|
||||||
|
generatedNames.insert(mo, className);
|
||||||
|
return className;
|
||||||
|
}
|
||||||
|
|
||||||
QSet<const QMetaObject *> collectReachableMetaObjects(const QList<QDeclarativeType *> &skip = QList<QDeclarativeType *>())
|
QSet<const QMetaObject *> collectReachableMetaObjects(const QList<QDeclarativeType *> &skip = QList<QDeclarativeType *>())
|
||||||
{
|
{
|
||||||
QSet<const QMetaObject *> metas;
|
QSet<const QMetaObject *> metas;
|
||||||
@@ -235,7 +260,7 @@ public:
|
|||||||
{
|
{
|
||||||
qml->writeStartObject("Component");
|
qml->writeStartObject("Component");
|
||||||
|
|
||||||
QByteArray id = convertToId(meta->className());
|
QByteArray id = convertToId(meta);
|
||||||
qml->writeScriptBinding(QLatin1String("name"), enquote(id));
|
qml->writeScriptBinding(QLatin1String("name"), enquote(id));
|
||||||
|
|
||||||
for (int index = meta->classInfoCount() - 1 ; index >= 0 ; --index) {
|
for (int index = meta->classInfoCount() - 1 ; index >= 0 ; --index) {
|
||||||
@@ -247,7 +272,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (meta->superClass())
|
if (meta->superClass())
|
||||||
qml->writeScriptBinding(QLatin1String("prototype"), enquote(convertToId(meta->superClass()->className())));
|
qml->writeScriptBinding(QLatin1String("prototype"), enquote(convertToId(meta->superClass())));
|
||||||
|
|
||||||
QSet<const QDeclarativeType *> qmlTypes = qmlTypesByCppName.value(meta->className());
|
QSet<const QDeclarativeType *> qmlTypes = qmlTypesByCppName.value(meta->className());
|
||||||
if (!qmlTypes.isEmpty()) {
|
if (!qmlTypes.isEmpty()) {
|
||||||
@@ -278,7 +303,7 @@ public:
|
|||||||
|
|
||||||
if (const QMetaObject *attachedType = (*qmlTypes.begin())->attachedPropertiesType()) {
|
if (const QMetaObject *attachedType = (*qmlTypes.begin())->attachedPropertiesType()) {
|
||||||
qml->writeScriptBinding(QLatin1String("attachedType"), enquote(
|
qml->writeScriptBinding(QLatin1String("attachedType"), enquote(
|
||||||
convertToId(attachedType->className())));
|
convertToId(attachedType)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -618,7 +643,7 @@ int main(int argc, char *argv[])
|
|||||||
// put the metaobjects into a map so they are always dumped in the same order
|
// put the metaobjects into a map so they are always dumped in the same order
|
||||||
QMap<QString, const QMetaObject *> nameToMeta;
|
QMap<QString, const QMetaObject *> nameToMeta;
|
||||||
foreach (const QMetaObject *meta, metas)
|
foreach (const QMetaObject *meta, metas)
|
||||||
nameToMeta.insert(convertToId(meta->className()), meta);
|
nameToMeta.insert(convertToId(meta), meta);
|
||||||
|
|
||||||
Dumper dumper(&qml);
|
Dumper dumper(&qml);
|
||||||
if (relocatable)
|
if (relocatable)
|
||||||
|
Reference in New Issue
Block a user