Commit ac25d70f authored by dt's avatar dt
Browse files

Don't crash if the session node is the current node in context menu

Probably fixes
Task-Nr: QTCREATORBUG-1697
parent 3c915709
......@@ -1212,7 +1212,7 @@ void ProjectExplorerPlugin::showContextMenu(const QPoint &globalPos, Node *node)
contextMenu = d->m_sessionContextMenu;
}
updateContextMenuActions();
updateContextMenuActions(node);
if (contextMenu && contextMenu->actions().count() > 0) {
contextMenu->popup(globalPos);
}
......@@ -1884,19 +1884,22 @@ void ProjectExplorerPlugin::goToTaskWindow()
d->m_buildManager->gotoTaskWindow();
}
void ProjectExplorerPlugin::updateContextMenuActions()
void ProjectExplorerPlugin::updateContextMenuActions(Node *node)
{
d->m_addExistingFilesAction->setEnabled(false);
d->m_addNewFileAction->setEnabled(false);
d->m_removeFileAction->setEnabled(false);
if (FolderNode *folderNode = qobject_cast<FolderNode*>(d->m_currentNode)) {
const bool addFilesEnabled = folderNode->projectNode()->supportedActions().contains(ProjectNode::AddFile);
d->m_addExistingFilesAction->setEnabled(addFilesEnabled);
d->m_addNewFileAction->setEnabled(addFilesEnabled);
} else if (FileNode *fileNode = qobject_cast<FileNode*>(d->m_currentNode)) {
const bool removeFileEnabled = fileNode->projectNode()->supportedActions().contains(ProjectNode::RemoveFile);
d->m_removeFileAction->setEnabled(removeFileEnabled);
if (node->projectNode()) {
QList<ProjectNode::ProjectAction> supportedActions = node->projectNode()->supportedActions();
if (qobject_cast<FolderNode*>(node)) {
const bool addFilesEnabled = supportedActions.contains(ProjectNode::AddFile);
d->m_addExistingFilesAction->setEnabled(addFilesEnabled);
d->m_addNewFileAction->setEnabled(addFilesEnabled);
} else if (qobject_cast<FileNode*>(node)) {
const bool removeFileEnabled = supportedActions.contains(ProjectNode::RemoveFile);
d->m_removeFileAction->setEnabled(removeFileEnabled);
}
}
}
......
......@@ -159,7 +159,6 @@ private slots:
void savePersistentSettings();
void goToTaskWindow();
void updateContextMenuActions();
void addNewFile();
void addExistingFiles();
void openFile();
......@@ -199,6 +198,7 @@ private slots:
#endif
private:
void updateContextMenuActions(Node *node);
bool parseArguments(const QStringList &arguments, QString *error);
void runProjectImpl(Project *pro, QString mode);
void executeRunConfiguration(RunConfiguration *, const QString &mode);
......
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