aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/designer
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2019-09-24 14:39:50 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2019-10-01 09:27:10 +0000
commit736eef24ca9263339f4c576cba5d4b20fe188045 (patch)
treeeb40889871ded25164d05cc235663c4b64c45ab5 /src/plugins/designer
parent85fcd10f90e3ccf8e8c5586fd84161145ef862a0 (diff)
Designer: Fix look-up of resources for UI files
Commit 81a643ec99, fixing QTCREATORBUG-22412, was too restrictive: UI files in applications have access to resources of library dependencies, so we must consider those. We now only exclude resources from other applications. Note that this will potentially list non-applicable resources, e.g. those from libraries to which our product does not have access. This cannot be reasonably prevented, because not all build systems provide this information. It's also not as bad as missing resources. Fixes: QTCREATORBUG-22909 Fixes: QTCREATORBUG-22962 Change-Id: I51a87402b43c156618982813c408060f300e4e58 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/designer')
-rw-r--r--src/plugins/designer/resourcehandler.cpp33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/plugins/designer/resourcehandler.cpp b/src/plugins/designer/resourcehandler.cpp
index 84020f77ee..c01dbc95f6 100644
--- a/src/plugins/designer/resourcehandler.cpp
+++ b/src/plugins/designer/resourcehandler.cpp
@@ -99,26 +99,37 @@ void ResourceHandler::updateResourcesHelper(bool updateProjectResources)
// 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) {
+ Node * const fileNode = project->rootProjectNode()->findNode([&fileName](const Node *n) {
return n->filePath().toString() == fileName;
});
+ ProjectNode *projectNodeForUiFile = nullptr;
if (fileNode) {
// We do not want qbs groups or qmake .pri files here, as they contain only a subset
// of the relevant files.
- projectNode = fileNode->parentProjectNode();
- while (projectNode && !projectNode->isProduct())
- projectNode = projectNode->parentProjectNode();
+ projectNodeForUiFile = fileNode->parentProjectNode();
+ while (projectNodeForUiFile && !projectNodeForUiFile->isProduct())
+ projectNodeForUiFile = projectNodeForUiFile->parentProjectNode();
}
- if (!projectNode)
- projectNode = project->rootProjectNode();
+ if (!projectNodeForUiFile)
+ projectNodeForUiFile = project->rootProjectNode();
+
+ const auto useQrcFile = [projectNodeForUiFile, project](const Node *qrcNode) {
+ if (projectNodeForUiFile == project->rootProjectNode())
+ return true;
+ ProjectNode *projectNodeForQrcFile = qrcNode->parentProjectNode();
+ while (projectNodeForQrcFile && !projectNodeForQrcFile->isProduct())
+ projectNodeForQrcFile = projectNodeForQrcFile->parentProjectNode();
+ return !projectNodeForQrcFile
+ || projectNodeForQrcFile == projectNodeForUiFile
+ || projectNodeForQrcFile->productType() != ProductType::App;
+ };
QStringList projectQrcFiles;
- projectNode->forEachNode([&](FileNode *node) {
- if (node->fileType() == FileType::Resource)
+ project->rootProjectNode()->forEachNode([&](FileNode *node) {
+ if (node->fileType() == FileType::Resource && useQrcFile(node))
projectQrcFiles.append(node->filePath().toString());
}, [&](FolderNode *node) {
- if (dynamic_cast<ResourceEditor::ResourceTopLevelNode *>(node))
+ if (dynamic_cast<ResourceEditor::ResourceTopLevelNode *>(node) && useQrcFile(node))
projectQrcFiles.append(node->filePath().toString());
});
// Check if the user has chosen to update the lacking resource inside designer
@@ -130,7 +141,7 @@ void ResourceHandler::updateResourcesHelper(bool updateProjectResources)
}
if (!qrcPathsToBeAdded.isEmpty()) {
m_handlingResources = true;
- projectNode->addFiles(qrcPathsToBeAdded);
+ projectNodeForUiFile->addFiles(qrcPathsToBeAdded);
m_handlingResources = false;
projectQrcFiles += qrcPathsToBeAdded;
}