From df6ace109e2aab4fd39bb25b1a4cade96a44ce9f Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Tue, 4 Nov 2014 17:40:29 +0100 Subject: [PATCH] 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 --- src/plugins/projectexplorer/session.cpp | 21 ++++++++++++++++++++- src/plugins/projectexplorer/session.h | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 83aea757bce..03f12e319b6 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -320,8 +320,14 @@ void SessionManager::addProjects(const QList &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(editor)) { + project->editorConfiguration()->configureEditor(textEditor); + } + } + } + } +} + void SessionManager::removeProjects(QList remove) { QMap resMap; diff --git a/src/plugins/projectexplorer/session.h b/src/plugins/projectexplorer/session.h index 0f02bc1b08c..2670614d201 100644 --- a/src/plugins/projectexplorer/session.h +++ b/src/plugins/projectexplorer/session.h @@ -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