forked from qt-creator/qt-creator
qmake: Make resource file contents available again
The Qml code model needs the contents of resource files. This was done using QmakeVfs::readVirtualFile, which is not correct, since it does not read data from files on disk. So fix this mistake by using QmakeVfs::readFile instead. Task-number: QTCREATORBUG-18140 Change-Id: I25fd07d63ab02764bdf3fa705e2ff025d6831581 Reviewed-by: Marco Benelli <marco.benelli@qt.io>
This commit is contained in:
@@ -162,14 +162,14 @@ static void createTree(const QmakePriFile *pri, QmakePriFileNode *node)
|
||||
for (const FileName &file : newFilePaths) {
|
||||
auto vfs = pri->project()->qmakeVfs();
|
||||
QString contents;
|
||||
QString errorMessage;
|
||||
// Prefer the cumulative file if it's non-empty, based on the assumption
|
||||
// that it contains more "stuff".
|
||||
vfs->readVirtualFile(file.toString(), QMakeVfs::VfsCumulative, &contents);
|
||||
vfs->readFile(file.toString(), QMakeVfs::VfsCumulative, &contents, &errorMessage);
|
||||
// If the cumulative evaluation botched the file too much, try the exact one.
|
||||
if (contents.isEmpty())
|
||||
vfs->readVirtualFile(file.toString(), QMakeVfs::VfsExact, &contents);
|
||||
auto resourceNode
|
||||
= new ResourceEditor::ResourceTopLevelNode(file, false, contents, vfolder);
|
||||
vfs->readFile(file.toString(), QMakeVfs::VfsExact, &contents, &errorMessage);
|
||||
auto resourceNode = new ResourceEditor::ResourceTopLevelNode(file, false, contents, vfolder);
|
||||
vfolder->addNode(resourceNode);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -358,14 +358,15 @@ void QmakeProject::updateQmlJSCodeModel()
|
||||
projectInfo.activeResourceFiles.append(exactResources);
|
||||
projectInfo.allResourceFiles.append(exactResources);
|
||||
projectInfo.allResourceFiles.append(cumulativeResources);
|
||||
QString errorMessage;
|
||||
foreach (const QString &rc, exactResources) {
|
||||
QString contents;
|
||||
if (m_qmakeVfs->readVirtualFile(rc, QMakeVfs::VfsExact, &contents))
|
||||
if (m_qmakeVfs->readFile(rc, QMakeVfs::VfsExact, &contents, &errorMessage) == QMakeVfs::ReadOk)
|
||||
projectInfo.resourceFileContents[rc] = contents;
|
||||
}
|
||||
foreach (const QString &rc, cumulativeResources) {
|
||||
QString contents;
|
||||
if (m_qmakeVfs->readVirtualFile(rc, QMakeVfs::VfsCumulative, &contents))
|
||||
if (m_qmakeVfs->readFile(rc, QMakeVfs::VfsCumulative, &contents, &errorMessage) == QMakeVfs::ReadOk)
|
||||
projectInfo.resourceFileContents[rc] = contents;
|
||||
}
|
||||
if (!hasQmlLib) {
|
||||
|
||||
Reference in New Issue
Block a user