forked from qt-creator/qt-creator
ProjectTree: Fall back to startupProject as current more often
Fall back to SessionManager::startupProject more often.
Creator used to have ProjectTree::currentProject return a nullptr
e.g. right after the first project is loaded via the menu (and before
the Project tree widget is 'touched'). It also returned nullptr
when closing a project via the menu (again till user interaction
with the Project tree widget).
I think this is wrong, especially in the light of %{CurrentProject:Foo}
macro expansion.
Change-Id: I1c980382548792181584ec3dfc0d919e939111d8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -158,7 +158,10 @@ void ProjectTree::updateFromProjectTreeWidget(ProjectTreeWidget *widget)
|
||||
Node *currentNode = widget->currentNode();
|
||||
Project *project = projectForNode(currentNode);
|
||||
|
||||
setCurrent(currentNode, project);
|
||||
if (!project)
|
||||
updateFromNode(nullptr); // Project was removed!
|
||||
else
|
||||
setCurrent(currentNode, project);
|
||||
}
|
||||
|
||||
void ProjectTree::updateFromDocumentManager()
|
||||
@@ -227,12 +230,14 @@ void ProjectTree::setCurrent(Node *node, Project *project)
|
||||
|
||||
void ProjectTree::sessionChanged()
|
||||
{
|
||||
if (m_currentProject)
|
||||
if (m_currentProject) {
|
||||
Core::DocumentManager::setDefaultLocationForNewFiles(m_currentProject->projectDirectory().toString());
|
||||
else if (SessionManager::startupProject())
|
||||
Core::DocumentManager::setDefaultLocationForNewFiles(SessionManager::startupProject()->projectDirectory().toString());
|
||||
else
|
||||
} else if (Project *project = SessionManager::startupProject()) {
|
||||
Core::DocumentManager::setDefaultLocationForNewFiles(project->projectDirectory().toString());
|
||||
updateFromNode(nullptr); // Make startup project current if there is no other current
|
||||
} else {
|
||||
Core::DocumentManager::setDefaultLocationForNewFiles(QString());
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user