diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2019-05-08 11:18:01 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2019-05-09 15:06:08 +0000 |
commit | 81a643ec99b1d20aab66a69b8c444bbbf696815a (patch) | |
tree | 5b99eaa328292d1a0fb51ce5b77640ffacc29174 /src/plugins/designer | |
parent | 4197746095f6684f19056e0dac583108add75686 (diff) |
Designer: Find only resources from the same product
E.g. in a qmake SUBDIRS project with two applications, the form editor
should only know about resources in the app that the current ui file
belongs to.
Fixes: QTCREATORBUG-22412
Change-Id: Iaa310e8cbd24d1bf519c66a949a52f9c636f3c1c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/designer')
-rw-r--r-- | src/plugins/designer/resourcehandler.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/plugins/designer/resourcehandler.cpp b/src/plugins/designer/resourcehandler.cpp index 0bbc4cb2cda..c8a5003c8b6 100644 --- a/src/plugins/designer/resourcehandler.cpp +++ b/src/plugins/designer/resourcehandler.cpp @@ -96,9 +96,28 @@ void ResourceHandler::updateResourcesHelper(bool updateProjectResources) // Does the file belong to a project? if (project) { // Collect project resource files. - ProjectNode *root = project->rootProjectNode(); + + // Find the (sub-)project the file belongs to. We don't want to find resources + // from other parts of the project tree, e.g. via a qmake subdirs project. + ProjectNode *projectNode = project->rootProjectNode(); + Node * const fileNode = projectNode->findNode([&fileName](const Node *n) { + return n->filePath().toString() == fileName; + }); + if (fileNode) { + // Slightly hacky: + // The node types do not tell us whether we are dealing with a proper "product", + // e.g. a qbs product or qmake .pro file. We do *not* want qbs groups + // or qmake .pri files here, as they contain only a subset of the relevant + // files. Luckily, the "show in simplified tree" property appears to match + // exactly what we want here. + do + projectNode = fileNode->parentProjectNode(); + while (projectNode && !projectNode->showInSimpleTree()); + } + QTC_ASSERT(projectNode, projectNode = project->rootProjectNode()); + QStringList projectQrcFiles; - root->forEachNode([&](FileNode *node) { + projectNode->forEachNode([&](FileNode *node) { if (node->fileType() == FileType::Resource) projectQrcFiles.append(node->filePath().toString()); }, [&](FolderNode *node) { @@ -114,7 +133,7 @@ void ResourceHandler::updateResourcesHelper(bool updateProjectResources) } if (!qrcPathsToBeAdded.isEmpty()) { m_handlingResources = true; - root->addFiles(qrcPathsToBeAdded); + projectNode->addFiles(qrcPathsToBeAdded); m_handlingResources = false; projectQrcFiles += qrcPathsToBeAdded; } |