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,6 +158,9 @@ void ProjectTree::updateFromProjectTreeWidget(ProjectTreeWidget *widget)
|
|||||||
Node *currentNode = widget->currentNode();
|
Node *currentNode = widget->currentNode();
|
||||||
Project *project = projectForNode(currentNode);
|
Project *project = projectForNode(currentNode);
|
||||||
|
|
||||||
|
if (!project)
|
||||||
|
updateFromNode(nullptr); // Project was removed!
|
||||||
|
else
|
||||||
setCurrent(currentNode, project);
|
setCurrent(currentNode, project);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,12 +230,14 @@ void ProjectTree::setCurrent(Node *node, Project *project)
|
|||||||
|
|
||||||
void ProjectTree::sessionChanged()
|
void ProjectTree::sessionChanged()
|
||||||
{
|
{
|
||||||
if (m_currentProject)
|
if (m_currentProject) {
|
||||||
Core::DocumentManager::setDefaultLocationForNewFiles(m_currentProject->projectDirectory().toString());
|
Core::DocumentManager::setDefaultLocationForNewFiles(m_currentProject->projectDirectory().toString());
|
||||||
else if (SessionManager::startupProject())
|
} else if (Project *project = SessionManager::startupProject()) {
|
||||||
Core::DocumentManager::setDefaultLocationForNewFiles(SessionManager::startupProject()->projectDirectory().toString());
|
Core::DocumentManager::setDefaultLocationForNewFiles(project->projectDirectory().toString());
|
||||||
else
|
updateFromNode(nullptr); // Make startup project current if there is no other current
|
||||||
|
} else {
|
||||||
Core::DocumentManager::setDefaultLocationForNewFiles(QString());
|
Core::DocumentManager::setDefaultLocationForNewFiles(QString());
|
||||||
|
}
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user