forked from qt-creator/qt-creator
Clang: Fix recovering on clangbackend crash
The translation unit was updated, but not re-registered. Handle the editor documents this way: 1. Reset all ClangEditorDocumentProcessors (this will send an unregister message, but that's not problematic). 2. For the visible editor documents, run their processors so that the translation units will be re-registered. 3. For the invisible editor documents, mark them dirty. Once the user makes an invisible document visible again, the processor will run and also re-register the translation unit. Change-Id: I23693ac197bd34a183f3a0020eb5372268636599 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
This commit is contained in:
@@ -476,15 +476,24 @@ void IpcCommunicator::registerCurrentProjectParts()
|
|||||||
registerProjectsParts(projectInfo.projectParts());
|
registerProjectsParts(projectInfo.projectParts());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcCommunicator::registerCurrentCppEditorDocuments()
|
void IpcCommunicator::restoreCppEditorDocuments()
|
||||||
|
{
|
||||||
|
resetCppEditorDocumentProcessors();
|
||||||
|
registerVisibleCppEditorDocumentAndMarkInvisibleDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcCommunicator::resetCppEditorDocumentProcessors()
|
||||||
{
|
{
|
||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
|
|
||||||
const auto cppEditorDocuments = CppModelManager::instance()->cppEditorDocuments();
|
const auto cppEditorDocuments = CppModelManager::instance()->cppEditorDocuments();
|
||||||
foreach (const CppEditorDocumentHandle *cppEditorDocument, cppEditorDocuments) {
|
foreach (CppEditorDocumentHandle *cppEditorDocument, cppEditorDocuments)
|
||||||
if (cppEditorDocument->processor()->baseTextDocument()->isModified())
|
cppEditorDocument->resetProcessor();
|
||||||
updateTranslationUnitFromCppEditorDocument(cppEditorDocument->filePath());
|
}
|
||||||
}
|
|
||||||
|
void IpcCommunicator::registerVisibleCppEditorDocumentAndMarkInvisibleDirty()
|
||||||
|
{
|
||||||
|
CppTools::CppModelManager::instance()->updateCppEditorDocuments();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcCommunicator::registerCurrentCodeModelUiHeaders()
|
void IpcCommunicator::registerCurrentCodeModelUiHeaders()
|
||||||
@@ -657,8 +666,8 @@ void IpcCommunicator::initializeBackendWithCurrentData()
|
|||||||
{
|
{
|
||||||
registerFallbackProjectPart();
|
registerFallbackProjectPart();
|
||||||
registerCurrentProjectParts();
|
registerCurrentProjectParts();
|
||||||
registerCurrentCppEditorDocuments();
|
|
||||||
registerCurrentCodeModelUiHeaders();
|
registerCurrentCodeModelUiHeaders();
|
||||||
|
restoreCppEditorDocuments();
|
||||||
updateTranslationUnitVisiblity();
|
updateTranslationUnitVisiblity();
|
||||||
|
|
||||||
emit backendReinitialized();
|
emit backendReinitialized();
|
||||||
|
@@ -169,7 +169,9 @@ private:
|
|||||||
void initializeBackend();
|
void initializeBackend();
|
||||||
void initializeBackendWithCurrentData();
|
void initializeBackendWithCurrentData();
|
||||||
void registerCurrentProjectParts();
|
void registerCurrentProjectParts();
|
||||||
void registerCurrentCppEditorDocuments();
|
void restoreCppEditorDocuments();
|
||||||
|
void resetCppEditorDocumentProcessors();
|
||||||
|
void registerVisibleCppEditorDocumentAndMarkInvisibleDirty();
|
||||||
void registerCurrentCodeModelUiHeaders();
|
void registerCurrentCodeModelUiHeaders();
|
||||||
|
|
||||||
|
|
||||||
|
@@ -91,6 +91,7 @@ public:
|
|||||||
|
|
||||||
QFuture<void> updateSourceFiles(const QSet<QString> &sourceFiles,
|
QFuture<void> updateSourceFiles(const QSet<QString> &sourceFiles,
|
||||||
ProgressNotificationMode mode = ReservedProgressNotification);
|
ProgressNotificationMode mode = ReservedProgressNotification);
|
||||||
|
void updateCppEditorDocuments() const;
|
||||||
WorkingCopy workingCopy() const;
|
WorkingCopy workingCopy() const;
|
||||||
QByteArray codeModelConfiguration() const;
|
QByteArray codeModelConfiguration() const;
|
||||||
|
|
||||||
@@ -209,7 +210,6 @@ private:
|
|||||||
void initializeModelManagerSupports();
|
void initializeModelManagerSupports();
|
||||||
void delayedGC();
|
void delayedGC();
|
||||||
void recalculateProjectPartMappings();
|
void recalculateProjectPartMappings();
|
||||||
void updateCppEditorDocuments() const;
|
|
||||||
|
|
||||||
void replaceSnapshot(const CPlusPlus::Snapshot &newSnapshot);
|
void replaceSnapshot(const CPlusPlus::Snapshot &newSnapshot);
|
||||||
void removeFilesFromSnapshot(const QSet<QString> &removedFiles);
|
void removeFilesFromSnapshot(const QSet<QString> &removedFiles);
|
||||||
|
Reference in New Issue
Block a user