forked from qt-creator/qt-creator
CppEditor: Fix missing editor defines on session load
The CppSourceProcessor initially expects the "<per-editor-defines>" pseudo-file in the working copy and then puts the resulting document into the snapshot. Therefore, if we reset the snapshot, we must put the data back into the working copy. Fixes: QTCREATORBUG-22584 Change-Id: I4e3fd0647cc35327a2e72547c81c4edc16a670b2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -51,7 +51,7 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
|
|||||||
ExtraState state = extraState();
|
ExtraState state = extraState();
|
||||||
WorkingCopy workingCopy = updateParams.workingCopy;
|
WorkingCopy workingCopy = updateParams.workingCopy;
|
||||||
|
|
||||||
bool invalidateSnapshot = false, invalidateConfig = false, editorDefinesChanged_ = false;
|
bool invalidateSnapshot = false, invalidateConfig = false;
|
||||||
|
|
||||||
CppModelManager *modelManager = CppModelManager::instance();
|
CppModelManager *modelManager = CppModelManager::instance();
|
||||||
QByteArray configFile = modelManager->codeModelConfiguration();
|
QByteArray configFile = modelManager->codeModelConfiguration();
|
||||||
@@ -97,7 +97,6 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
|
|||||||
if (baseConfig.editorDefines != baseState.editorDefines) {
|
if (baseConfig.editorDefines != baseState.editorDefines) {
|
||||||
baseState.editorDefines = baseConfig.editorDefines;
|
baseState.editorDefines = baseConfig.editorDefines;
|
||||||
invalidateSnapshot = true;
|
invalidateSnapshot = true;
|
||||||
editorDefinesChanged_ = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (headerPaths != state.headerPaths) {
|
if (headerPaths != state.headerPaths) {
|
||||||
@@ -130,6 +129,10 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
|
|||||||
|
|
||||||
if (invalidateSnapshot) {
|
if (invalidateSnapshot) {
|
||||||
state.snapshot = Snapshot();
|
state.snapshot = Snapshot();
|
||||||
|
if (!baseState.editorDefines.isEmpty()) {
|
||||||
|
workingCopy.insert(CppModelManager::editorConfigurationFileName(),
|
||||||
|
baseState.editorDefines);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Remove changed files from the snapshot
|
// Remove changed files from the snapshot
|
||||||
QSet<Utils::FilePath> toRemove;
|
QSet<Utils::FilePath> toRemove;
|
||||||
@@ -161,13 +164,6 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
|
|||||||
workingCopy.insert(configurationFileName, state.configFile);
|
workingCopy.insert(configurationFileName, state.configFile);
|
||||||
state.snapshot.remove(filePath());
|
state.snapshot.remove(filePath());
|
||||||
|
|
||||||
static const QString editorDefinesFileName
|
|
||||||
= CppModelManager::editorConfigurationFileName();
|
|
||||||
if (editorDefinesChanged_) {
|
|
||||||
state.snapshot.remove(editorDefinesFileName);
|
|
||||||
workingCopy.insert(editorDefinesFileName, baseState.editorDefines);
|
|
||||||
}
|
|
||||||
|
|
||||||
Internal::CppSourceProcessor sourceProcessor(state.snapshot, [&](const Document::Ptr &doc) {
|
Internal::CppSourceProcessor sourceProcessor(state.snapshot, [&](const Document::Ptr &doc) {
|
||||||
const QString fileName = doc->fileName();
|
const QString fileName = doc->fileName();
|
||||||
const bool isInEditor = fileName == filePath();
|
const bool isInEditor = fileName == filePath();
|
||||||
@@ -197,7 +193,7 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
|
|||||||
sourceProcessor.run(precompiledHeader);
|
sourceProcessor.run(precompiledHeader);
|
||||||
}
|
}
|
||||||
if (!baseState.editorDefines.isEmpty())
|
if (!baseState.editorDefines.isEmpty())
|
||||||
sourceProcessor.run(editorDefinesFileName);
|
sourceProcessor.run(CppModelManager::editorConfigurationFileName());
|
||||||
QStringList includedFiles = state.includedFiles;
|
QStringList includedFiles = state.includedFiles;
|
||||||
if (baseConfig.usePrecompiledHeaders)
|
if (baseConfig.usePrecompiledHeaders)
|
||||||
includedFiles << state.precompiledHeaders;
|
includedFiles << state.precompiledHeaders;
|
||||||
|
|||||||
Reference in New Issue
Block a user