From e7e557cea2f35031cf3a51fcb8fa7a275625830f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 29 Mar 2019 16:05:25 +0100 Subject: moc: Add a standard way of specifying a URI as part of Q_PLUGIN_METADATA Usually, when you load a plugin, you don't want to load just any plugin that fulfills a given interface, but rather a specific one. When loading dynamic plugins you can differentiate the plugins by file name. This doesn't work in the static case, and file names are also separate from the plugin metadata shipped inside the plugin files. To solve this problem, different hacks have been developed in various places. QML extension plugins add a special property "uri" via the -M option of moc, QML debug plugins expect you to add a json file with an array of "Keys", Qt Creator plugins have a "Name" in their json files, etc. By allowing the identifier for the plugin to be specified inline with the metadata declaration we can make many of the above workarounds obsolete and provide a clean way for users to find their plugins. Task-number: QTBUG-74775 Change-Id: Ie2af16c49d4c5aa5a77fab0fae1e0a4449bd7a39 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/moc.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/tools/moc/moc.cpp') diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 2f52dd6ca0..7f43917f7e 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1311,6 +1311,9 @@ void Moc::parsePluginData(ClassDef *def) if (l == "IID") { next(STRING_LITERAL); def->pluginData.iid = unquotedLexem(); + } else if (l == "URI") { + next(STRING_LITERAL); + def->pluginData.uri = unquotedLexem(); } else if (l == "FILE") { next(STRING_LITERAL); QByteArray metaDataFile = unquotedLexem(); @@ -1351,6 +1354,7 @@ void Moc::parsePluginData(ClassDef *def) + " does not contain a valid JSON object. Declaration will be ignored"; warning(msg.constData()); def->pluginData.iid = QByteArray(); + def->pluginData.uri = QByteArray(); return; } } -- cgit v1.2.3