Commit 06615843 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Qbs: Do not crash when using simplified project view



Root cause is trying to set the display name on a FolderNode that
is not in the tree yet.

Allow setting the displayname in the constructor and use that new
constructor where it makes sense.

Task-number: QTCREATORBUG-12897
Change-Id: I907e48cac837966e38524bfe88a87ef17d93f0b2
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 917aa106
......@@ -247,10 +247,12 @@ bool FileNode::isGenerated() const
\sa ProjectExplorer::FileNode, ProjectExplorer::ProjectNode
*/
FolderNode::FolderNode(const QString &folderPath, NodeType nodeType) :
FolderNode::FolderNode(const QString &folderPath, NodeType nodeType, const QString &displayName) :
Node(nodeType, folderPath),
m_displayName(QDir::toNativeSeparators(folderPath))
m_displayName(displayName)
{
if (m_displayName.isEmpty())
m_displayName = QDir::toNativeSeparators(folderPath);
}
FolderNode::~FolderNode()
......
......@@ -162,7 +162,8 @@ private:
class PROJECTEXPLORER_EXPORT FolderNode : public Node {
Q_OBJECT
public:
explicit FolderNode(const QString &folderPath, NodeType nodeType = FolderNodeType);
explicit FolderNode(const QString &folderPath, NodeType nodeType = FolderNodeType,
const QString &displayName = QString());
virtual ~FolderNode();
QString displayName() const;
......
......@@ -527,14 +527,15 @@ void QbsGroupNode::setupFolder(ProjectExplorer::FolderNode *root,
break;
}
if (!fn) {
fn = new FolderNode(c->path());
fn = new FolderNode(c->path(), ProjectExplorer::FolderNodeType,
displayNameFromPath(c->path(), baseDir));
root->addFolderNodes(QList<FolderNode *>() << fn);
} else {
foldersToRemove.removeOne(fn);
if (updateExisting)
fn->emitNodeUpdated();
fn->setDisplayName(displayNameFromPath(c->path(), baseDir));
}
fn->setDisplayName(displayNameFromPath(c->path(), baseDir));
setupFolder(fn, c, c->path(), updateExisting);
}
......@@ -811,9 +812,9 @@ QbsProjectNode *QbsProjectNode::findProjectNode(const QString &name)
QbsRootProjectNode::QbsRootProjectNode(QbsProject *project) :
QbsProjectNode(project->projectFilePath().toString()),
m_project(project),
m_buildSystemFiles(new ProjectExplorer::FolderNode(project->projectDirectory().toString()))
m_buildSystemFiles(new ProjectExplorer::FolderNode(project->projectDirectory().toString(),
ProjectExplorer::FolderNodeType, tr("Qbs files")))
{
m_buildSystemFiles->setDisplayName(tr("Qbs files"));
addFolderNodes(QList<FolderNode *>() << m_buildSystemFiles);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment