forked from qt-creator/qt-creator
SessionManager; configureEditors on project opening/parsing
So far editors were only configured on opening, which meant that if a project was opened after the file was already open, the editor settings were wrong. This commit fixes that by connecting to project opening. Also due to changes in how qmake projects are parsed on initial opening the project has a empty filelist. Connecting to fileListChanged() fixes that too. Task-number: QTCREATORBUG-13299 Change-Id: Ia648818c8c0adb9c6e5047b8c855b1f6790a7ae2 Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -320,8 +320,14 @@ void SessionManager::addProjects(const QList<Project*> &projects)
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Project *pro, clearedList)
|
||||
foreach (Project *pro, clearedList) {
|
||||
emit m_instance->projectAdded(pro);
|
||||
configureEditors(pro);
|
||||
connect(pro, &Project::fileListChanged,
|
||||
[pro](){
|
||||
configureEditors(pro);
|
||||
});
|
||||
}
|
||||
|
||||
if (clearedList.count() == 1)
|
||||
emit m_instance->singleProjectAdded(clearedList.first());
|
||||
@@ -611,6 +617,19 @@ void SessionManager::configureEditor(Core::IEditor *editor, const QString &fileN
|
||||
}
|
||||
}
|
||||
|
||||
void SessionManager::configureEditors(Project *project)
|
||||
{
|
||||
foreach (IDocument *document, DocumentModel::openedDocuments()) {
|
||||
if (d->projectContainsFile(project, document->filePath())) {
|
||||
foreach (IEditor *editor, DocumentModel::editorsForDocument(document)) {
|
||||
if (TextEditor::BaseTextEditor *textEditor = qobject_cast<TextEditor::BaseTextEditor*>(editor)) {
|
||||
project->editorConfiguration()->configureEditor(textEditor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SessionManager::removeProjects(QList<Project *> remove)
|
||||
{
|
||||
QMap<QString, QStringList> resMap;
|
||||
|
@@ -147,6 +147,8 @@ private slots:
|
||||
static void configureEditor(Core::IEditor *editor, const QString &fileName);
|
||||
static void markSessionFileDirty(bool makeDefaultVirginDirty = true);
|
||||
static void projectDisplayNameChanged();
|
||||
private:
|
||||
static void configureEditors(Project *project);
|
||||
};
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
Reference in New Issue
Block a user