CMake: Fix possible crash before the project is fully set up

Change-Id: Iacbf49e296a72176ae828fa11286432212078694
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Tobias Hunger
2017-03-16 15:25:13 +01:00
parent 2ff0d30829
commit 9f1a9078c2

View File

@@ -310,13 +310,15 @@ QString CMakeProject::displayName() const
QStringList CMakeProject::files(FilesMode fileMode) const
{
QStringList result;
rootProjectNode()->forEachNode([&](const FileNode *fn) {
if (ProjectNode *rpn = rootProjectNode()) {
rpn->forEachNode([&](const FileNode *fn) {
const bool isGenerated = fn->isGenerated();
if (fileMode == Project::SourceFiles && !isGenerated)
result.append(fn->filePath().toString());
if (fileMode == Project::GeneratedFiles && isGenerated)
result.append(fn->filePath().toString());
});
}
return result;
}