forked from qt-creator/qt-creator
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 <orgads@gmail.com> Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -237,6 +237,7 @@ struct ProjectExplorerPluginPrivate {
|
|||||||
KitManager *m_kitManager;
|
KitManager *m_kitManager;
|
||||||
ToolChainManager *m_toolChainManager;
|
ToolChainManager *m_toolChainManager;
|
||||||
bool m_shuttingDown;
|
bool m_shuttingDown;
|
||||||
|
bool m_ignoreDocumentManagerChangedFile;
|
||||||
QStringList m_arguments;
|
QStringList m_arguments;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -248,7 +249,8 @@ ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() :
|
|||||||
m_projectsMode(0),
|
m_projectsMode(0),
|
||||||
m_kitManager(0),
|
m_kitManager(0),
|
||||||
m_toolChainManager(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)
|
void ProjectExplorerPlugin::setCurrentFile(const QString &filePath)
|
||||||
{
|
{
|
||||||
|
if (d->m_ignoreDocumentManagerChangedFile)
|
||||||
|
return;
|
||||||
Project *project = d->m_session->projectForFile(filePath);
|
Project *project = d->m_session->projectForFile(filePath);
|
||||||
// If the file is not in any project, stay with the current project
|
// 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
|
// 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();
|
updateActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d->m_ignoreDocumentManagerChangedFile = true;
|
||||||
Core::DocumentManager::setCurrentFile(filePath);
|
Core::DocumentManager::setCurrentFile(filePath);
|
||||||
updateContext();
|
updateContext();
|
||||||
|
d->m_ignoreDocumentManagerChangedFile = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectExplorerPlugin::updateActions()
|
void ProjectExplorerPlugin::updateActions()
|
||||||
|
Reference in New Issue
Block a user