aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/resourceeditor
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2017-05-16 14:08:57 +0200
committerTobias Hunger <tobias.hunger@qt.io>2017-05-17 11:31:56 +0000
commit800d5822efe262c1f6cdf9597392bb35791fb0ac (patch)
treed181d86b244b56dcd43a8159d6069502341d883e /src/plugins/resourceeditor
parent3e9f1672b7758ad2942191452f5dc42177c3c172 (diff)
Resources: Read qrc file contents from file if that is readable
Retrieve the qrc file contents from the file if that is readable. This is now necessary since the ResourceTopLevelNode now contains the QRC file contents itself so the QML code model has access to it, even if a qrc file is actually used. This fixes one part of QTCREATORBUG-17930 Task-number: QTCREATORBUG-17930 Change-Id: I0e8cc8828062f079d8634882a768ca60331a0e16 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/plugins/resourceeditor')
-rw-r--r--src/plugins/resourceeditor/resourcenode.cpp10
-rw-r--r--src/plugins/resourceeditor/resourcenode.h2
2 files changed, 7 insertions, 5 deletions
diff --git a/src/plugins/resourceeditor/resourcenode.cpp b/src/plugins/resourceeditor/resourcenode.cpp
index 20f67b2eec..354f56c4ee 100644
--- a/src/plugins/resourceeditor/resourcenode.cpp
+++ b/src/plugins/resourceeditor/resourcenode.cpp
@@ -270,12 +270,14 @@ ResourceTopLevelNode::ResourceTopLevelNode(const FileName &filePath, bool genera
{
setIsGenerated(generated);
setIcon(FileIconProvider::icon(filePath.toString()));
- if (contents.isEmpty()) {
- m_document = new ResourceFileWatcher(this);
- DocumentManager::addDocument(m_document);
+ if (!filePath.isEmpty()) {
+ QFileInfo fi = filePath.toFileInfo();
+ if (fi.isFile() && fi.isReadable()) {
+ m_document = new ResourceFileWatcher(this);
+ DocumentManager::addDocument(m_document);
+ }
} else {
m_contents = contents;
- m_document = nullptr;
}
FileName base = parent->filePath();
diff --git a/src/plugins/resourceeditor/resourcenode.h b/src/plugins/resourceeditor/resourcenode.h
index f1377eaa14..e2f84e005a 100644
--- a/src/plugins/resourceeditor/resourcenode.h
+++ b/src/plugins/resourceeditor/resourcenode.h
@@ -56,7 +56,7 @@ public:
QString contents() const { return m_contents; }
private:
- Internal::ResourceFileWatcher *m_document;
+ Internal::ResourceFileWatcher *m_document = nullptr;
QString m_contents;
};