Navigation Menu

Skip to content

Commit

Permalink
[qtdeclarative] Dump types reachable through internal dependencies. C…
Browse files Browse the repository at this point in the history
…ontributes to JB#46800

Do not exclude types that are reachable through dependencies, but only
become registered (exported) after the dumped module is imported.  This
happens e.g. when a private submodule exists as a dependency and it
extends types from the public module. The extended types become
reachable when the private submodule is loaded as a dependency, but only
become registered (exported) after the public module is loaded.
  • Loading branch information
martyone committed Jan 17, 2020
1 parent 7bd6917 commit 57292c9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tools/qmlplugindump/main.cpp
Expand Up @@ -1197,6 +1197,14 @@ int main(int argc, char *argv[])
importCode += QString("\nimport \".\" %2\n").arg(pluginImportVersion).toLatin1();
}

// collect QMetaObjects that are reachable through dependencies but only become registered
// after the specified modules is imported
QSet<const QMetaObject *> defaultReachableNotExported;
foreach (const QMetaObject *mo, defaultReachable) {
if (!QQmlMetaType::qmlType(mo))
defaultReachableNotExported.insert(mo);
}

// create a component with these imports to make sure the imports are valid
// and to populate the declarative meta type system
{
Expand All @@ -1213,6 +1221,24 @@ int main(int argc, char *argv[])
}
}

// only keep those that really became registered (exported)
for (auto i = defaultReachableNotExported.begin(); i != defaultReachableNotExported.end(); ) {
QQmlType *ty = QQmlMetaType::qmlType(*i);
if (!ty || ty->module().isEmpty())
i = defaultReachableNotExported.erase(i);
else
++i;
}

if (verbose && !defaultReachableNotExported.isEmpty()) {
std::cerr << "Objects reachable through dependencies, but only exported by "
<< qPrintable( pluginImportUri ) << ":" << std::endl;
foreach (const QMetaObject *mo, defaultReachableNotExported)
std::cerr << " " << qPrintable( mo->className() ) << std::endl;
}

defaultReachable.subtract(defaultReachableNotExported);

QSet<const QMetaObject *> candidates = collectReachableMetaObjects(&engine, uncreatableMetas, singletonMetas, defaultTypes);
candidates.subtract(defaultReachable);

Expand Down

0 comments on commit 57292c9

Please sign in to comment.