Commit d0dc6805 authored by Daniel Teske's avatar Daniel Teske

ProjectModels: Fix crash on changing the tree in particular ways

The crash is due to the project model figuring out a safe node to be the
current node, setting that. But then the DocumentManager synchronizes
the current node with the editor, thus setting the current node back.

Task-number: QTCREATORBUG-9176
Change-Id: Ia516a770dbbfd16d224fa030a8c3d1b3a40f83cd
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 5219faf0
......@@ -237,6 +237,7 @@ struct ProjectExplorerPluginPrivate {
KitManager *m_kitManager;
ToolChainManager *m_toolChainManager;
bool m_shuttingDown;
bool m_ignoreDocumentManagerChangedFile;
QStringList m_arguments;
};
......@@ -248,7 +249,8 @@ ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() :
m_projectsMode(0),
m_kitManager(0),
m_toolChainManager(0),
m_shuttingDown(false)
m_shuttingDown(false),
m_ignoreDocumentManagerChangedFile(false)
{
}
......@@ -1413,6 +1415,8 @@ void ProjectExplorerPlugin::setCurrentFile(Project *project, const QString &file
void ProjectExplorerPlugin::setCurrentFile(const QString &filePath)
{
if (d->m_ignoreDocumentManagerChangedFile)
return;
Project *project = d->m_session->projectForFile(filePath);
// If the file is not in any project, stay with the current project
// e.g. on opening a git diff buffer, git log buffer, we don't change the project
......@@ -1826,8 +1830,10 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node
updateActions();
}
d->m_ignoreDocumentManagerChangedFile = true;
Core::DocumentManager::setCurrentFile(filePath);
updateContext();
d->m_ignoreDocumentManagerChangedFile = false;
}
void ProjectExplorerPlugin::updateActions()
......
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