forked from qt-creator/qt-creator
C++: Fix crash after triggering completion and closing editor
Fix use-after-free for the following case: 1. Open an editor 2. Trigger a long processing completion (e.g. simulate with QThread::msleep in CppCompletionAssistInterface::getCppSpecifics) 3. ...and immediately close the editor (e.g. with Ctrl+W) 4. Wait until it crashes. The completion thread relied on the BuiltinEditorDocumentParser object, which is deleted once the editor is closed. Fixed by sharing the ownership of that object between the *EditorDocumentProcessor and the completion assist interface. This case came up when doing tests for the bug report below. Task-number: QTCREATORBUG-14991 Change-Id: I0b009229e68fc6b7838740858cdc41a32403fe6f Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
@@ -94,7 +94,7 @@ ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(
|
|||||||
TextEditor::TextDocument *document)
|
TextEditor::TextDocument *document)
|
||||||
: BaseEditorDocumentProcessor(document)
|
: BaseEditorDocumentProcessor(document)
|
||||||
, m_modelManagerSupport(modelManagerSupport)
|
, m_modelManagerSupport(modelManagerSupport)
|
||||||
, m_parser(document->filePath().toString())
|
, m_parser(new ClangEditorDocumentParser(document->filePath().toString()))
|
||||||
, m_parserRevision(0)
|
, m_parserRevision(0)
|
||||||
, m_semanticHighlighter(document)
|
, m_semanticHighlighter(document)
|
||||||
, m_builtinProcessor(document, /*enableSemanticHighlighter=*/ false)
|
, m_builtinProcessor(document, /*enableSemanticHighlighter=*/ false)
|
||||||
@@ -114,7 +114,7 @@ ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(
|
|||||||
const int firstLine = 1;
|
const int firstLine = 1;
|
||||||
const int lastLine = baseTextDocument()->document()->blockCount();
|
const int lastLine = baseTextDocument()->document()->blockCount();
|
||||||
|
|
||||||
CreateMarkers *createMarkers = CreateMarkers::create(m_parser.semanticMarker(),
|
CreateMarkers *createMarkers = CreateMarkers::create(m_parser->semanticMarker(),
|
||||||
baseTextDocument()->filePath().toString(),
|
baseTextDocument()->filePath().toString(),
|
||||||
firstLine, lastLine);
|
firstLine, lastLine);
|
||||||
return createMarkers->start();
|
return createMarkers->start();
|
||||||
@@ -169,9 +169,9 @@ CppTools::SemanticInfo ClangEditorDocumentProcessor::recalculateSemanticInfo()
|
|||||||
return m_builtinProcessor.recalculateSemanticInfo();
|
return m_builtinProcessor.recalculateSemanticInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
CppTools::BaseEditorDocumentParser *ClangEditorDocumentProcessor::parser()
|
CppTools::BaseEditorDocumentParser::Ptr ClangEditorDocumentProcessor::parser()
|
||||||
{
|
{
|
||||||
return &m_parser;
|
return m_parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPlusPlus::Snapshot ClangEditorDocumentProcessor::snapshot()
|
CPlusPlus::Snapshot ClangEditorDocumentProcessor::snapshot()
|
||||||
@@ -196,7 +196,7 @@ ClangEditorDocumentProcessor *ClangEditorDocumentProcessor::get(const QString &f
|
|||||||
|
|
||||||
void ClangEditorDocumentProcessor::updateProjectPartAndTranslationUnitForCompletion()
|
void ClangEditorDocumentProcessor::updateProjectPartAndTranslationUnitForCompletion()
|
||||||
{
|
{
|
||||||
const CppTools::ProjectPart::Ptr projectPart = m_parser.projectPart();
|
const CppTools::ProjectPart::Ptr projectPart = m_parser->projectPart();
|
||||||
QTC_ASSERT(projectPart, return);
|
QTC_ASSERT(projectPart, return);
|
||||||
|
|
||||||
updateTranslationUnitForCompletion(*projectPart.data());
|
updateTranslationUnitForCompletion(*projectPart.data());
|
||||||
@@ -209,11 +209,11 @@ void ClangEditorDocumentProcessor::onParserFinished()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Emit ifdefed out blocks
|
// Emit ifdefed out blocks
|
||||||
const auto ifdefoutBlocks = toTextEditorBlocks(m_parser.ifdefedOutBlocks());
|
const auto ifdefoutBlocks = toTextEditorBlocks(m_parser->ifdefedOutBlocks());
|
||||||
emit ifdefedOutBlocksUpdated(revision(), ifdefoutBlocks);
|
emit ifdefedOutBlocksUpdated(revision(), ifdefoutBlocks);
|
||||||
|
|
||||||
// Emit code warnings
|
// Emit code warnings
|
||||||
const auto diagnostics = toCppToolsDiagnostics(filePath(), m_parser.diagnostics());
|
const auto diagnostics = toCppToolsDiagnostics(filePath(), m_parser->diagnostics());
|
||||||
const auto codeWarnings = toTextEditorSelections(diagnostics, textDocument());
|
const auto codeWarnings = toTextEditorSelections(diagnostics, textDocument());
|
||||||
emit codeWarningsUpdated(revision(), codeWarnings);
|
emit codeWarningsUpdated(revision(), codeWarnings);
|
||||||
|
|
||||||
|
@@ -59,7 +59,7 @@ public:
|
|||||||
void semanticRehighlight() override;
|
void semanticRehighlight() override;
|
||||||
void recalculateSemanticInfoDetached(bool force) override;
|
void recalculateSemanticInfoDetached(bool force) override;
|
||||||
CppTools::SemanticInfo recalculateSemanticInfo() override;
|
CppTools::SemanticInfo recalculateSemanticInfo() override;
|
||||||
CppTools::BaseEditorDocumentParser *parser() override;
|
CppTools::BaseEditorDocumentParser::Ptr parser() override;
|
||||||
CPlusPlus::Snapshot snapshot() override;
|
CPlusPlus::Snapshot snapshot() override;
|
||||||
bool isParserRunning() const override;
|
bool isParserRunning() const override;
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ private:
|
|||||||
|
|
||||||
QPointer<ModelManagerSupportClang> m_modelManagerSupport;
|
QPointer<ModelManagerSupportClang> m_modelManagerSupport;
|
||||||
|
|
||||||
ClangEditorDocumentParser m_parser;
|
QSharedPointer<ClangEditorDocumentParser> m_parser;
|
||||||
CppTools::ProjectPart::Ptr m_projectPart;
|
CppTools::ProjectPart::Ptr m_projectPart;
|
||||||
QFutureWatcher<void> m_parserWatcher;
|
QFutureWatcher<void> m_parserWatcher;
|
||||||
unsigned m_parserRevision;
|
unsigned m_parserRevision;
|
||||||
|
@@ -234,7 +234,7 @@ QStringList createPCHInclusionOptions(const QString &pchFile)
|
|||||||
|
|
||||||
ProjectPart::Ptr projectPartForFile(const QString &filePath)
|
ProjectPart::Ptr projectPartForFile(const QString &filePath)
|
||||||
{
|
{
|
||||||
if (CppTools::BaseEditorDocumentParser *parser = CppTools::BaseEditorDocumentParser::get(filePath))
|
if (const auto parser = CppTools::BaseEditorDocumentParser::get(filePath))
|
||||||
return parser->projectPart();
|
return parser->projectPart();
|
||||||
return ProjectPart::Ptr();
|
return ProjectPart::Ptr();
|
||||||
}
|
}
|
||||||
|
@@ -266,7 +266,7 @@ void CppEditorDocument::updatePreprocessorSettings()
|
|||||||
void CppEditorDocument::setPreprocessorSettings(const CppTools::ProjectPart::Ptr &projectPart,
|
void CppEditorDocument::setPreprocessorSettings(const CppTools::ProjectPart::Ptr &projectPart,
|
||||||
const QByteArray &defines)
|
const QByteArray &defines)
|
||||||
{
|
{
|
||||||
CppTools::BaseEditorDocumentParser *parser = processor()->parser();
|
const auto parser = processor()->parser();
|
||||||
QTC_ASSERT(parser, return);
|
QTC_ASSERT(parser, return);
|
||||||
if (parser->projectPart() != projectPart || parser->configuration().editorDefines != defines) {
|
if (parser->projectPart() != projectPart || parser->configuration().editorDefines != defines) {
|
||||||
CppTools::BaseEditorDocumentParser::Configuration config = parser->configuration();
|
CppTools::BaseEditorDocumentParser::Configuration config = parser->configuration();
|
||||||
|
@@ -104,14 +104,14 @@ ProjectPart::Ptr BaseEditorDocumentParser::projectPart() const
|
|||||||
return state().projectPart;
|
return state().projectPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseEditorDocumentParser *BaseEditorDocumentParser::get(const QString &filePath)
|
BaseEditorDocumentParser::Ptr BaseEditorDocumentParser::get(const QString &filePath)
|
||||||
{
|
{
|
||||||
CppModelManager *cmmi = CppModelManager::instance();
|
CppModelManager *cmmi = CppModelManager::instance();
|
||||||
if (CppEditorDocumentHandle *cppEditorDocument = cmmi->cppEditorDocument(filePath)) {
|
if (CppEditorDocumentHandle *cppEditorDocument = cmmi->cppEditorDocument(filePath)) {
|
||||||
if (BaseEditorDocumentProcessor *processor = cppEditorDocument->processor())
|
if (BaseEditorDocumentProcessor *processor = cppEditorDocument->processor())
|
||||||
return processor->parser();
|
return processor->parser();
|
||||||
}
|
}
|
||||||
return 0;
|
return BaseEditorDocumentParser::Ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectPart::Ptr BaseEditorDocumentParser::determineProjectPart(const QString &filePath,
|
ProjectPart::Ptr BaseEditorDocumentParser::determineProjectPart(const QString &filePath,
|
||||||
|
@@ -44,7 +44,8 @@ class CPPTOOLS_EXPORT BaseEditorDocumentParser : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static BaseEditorDocumentParser *get(const QString &filePath);
|
using Ptr = QSharedPointer<BaseEditorDocumentParser>;;
|
||||||
|
static Ptr get(const QString &filePath);
|
||||||
|
|
||||||
struct Configuration {
|
struct Configuration {
|
||||||
bool stickToPreviousProjectPart = true;
|
bool stickToPreviousProjectPart = true;
|
||||||
|
@@ -118,7 +118,7 @@ QList<QTextEdit::ExtraSelection> BaseEditorDocumentProcessor::toTextEditorSelect
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BaseEditorDocumentProcessor::runParser(QFutureInterface<void> &future,
|
void BaseEditorDocumentProcessor::runParser(QFutureInterface<void> &future,
|
||||||
BaseEditorDocumentParser *parser,
|
BaseEditorDocumentParser::Ptr parser,
|
||||||
BaseEditorDocumentParser::InMemoryInfo info)
|
BaseEditorDocumentParser::InMemoryInfo info)
|
||||||
{
|
{
|
||||||
future.setProgressRange(0, 1);
|
future.setProgressRange(0, 1);
|
||||||
|
@@ -62,7 +62,7 @@ public:
|
|||||||
virtual void recalculateSemanticInfoDetached(bool force) = 0;
|
virtual void recalculateSemanticInfoDetached(bool force) = 0;
|
||||||
virtual CppTools::SemanticInfo recalculateSemanticInfo() = 0;
|
virtual CppTools::SemanticInfo recalculateSemanticInfo() = 0;
|
||||||
virtual CPlusPlus::Snapshot snapshot() = 0;
|
virtual CPlusPlus::Snapshot snapshot() = 0;
|
||||||
virtual BaseEditorDocumentParser *parser() = 0;
|
virtual BaseEditorDocumentParser::Ptr parser() = 0;
|
||||||
virtual bool isParserRunning() const = 0;
|
virtual bool isParserRunning() const = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -85,7 +85,7 @@ protected:
|
|||||||
QTextDocument *textDocument);
|
QTextDocument *textDocument);
|
||||||
|
|
||||||
static void runParser(QFutureInterface<void> &future,
|
static void runParser(QFutureInterface<void> &future,
|
||||||
CppTools::BaseEditorDocumentParser *parser,
|
BaseEditorDocumentParser::Ptr parser,
|
||||||
BaseEditorDocumentParser::InMemoryInfo info);
|
BaseEditorDocumentParser::InMemoryInfo info);
|
||||||
|
|
||||||
// Convenience
|
// Convenience
|
||||||
|
@@ -226,11 +226,11 @@ ProjectPart::HeaderPaths BuiltinEditorDocumentParser::headerPaths() const
|
|||||||
return extraState().headerPaths;
|
return extraState().headerPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
BuiltinEditorDocumentParser *BuiltinEditorDocumentParser::get(const QString &filePath)
|
BuiltinEditorDocumentParser::Ptr BuiltinEditorDocumentParser::get(const QString &filePath)
|
||||||
{
|
{
|
||||||
if (BaseEditorDocumentParser *b = BaseEditorDocumentParser::get(filePath))
|
if (BaseEditorDocumentParser::Ptr b = BaseEditorDocumentParser::get(filePath))
|
||||||
return qobject_cast<BuiltinEditorDocumentParser *>(b);
|
return b.objectCast<BuiltinEditorDocumentParser>();
|
||||||
return 0;
|
return BuiltinEditorDocumentParser::Ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuiltinEditorDocumentParser::addFileAndDependencies(Snapshot *snapshot,
|
void BuiltinEditorDocumentParser::addFileAndDependencies(Snapshot *snapshot,
|
||||||
|
@@ -61,7 +61,8 @@ signals:
|
|||||||
void finished(CPlusPlus::Document::Ptr document, CPlusPlus::Snapshot snapshot);
|
void finished(CPlusPlus::Document::Ptr document, CPlusPlus::Snapshot snapshot);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static BuiltinEditorDocumentParser *get(const QString &filePath);
|
using Ptr = QSharedPointer<BuiltinEditorDocumentParser>;
|
||||||
|
static Ptr get(const QString &filePath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateHelper(const InMemoryInfo &info) override;
|
void updateHelper(const InMemoryInfo &info) override;
|
||||||
|
@@ -125,7 +125,7 @@ BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(
|
|||||||
TextEditor::TextDocument *document,
|
TextEditor::TextDocument *document,
|
||||||
bool enableSemanticHighlighter)
|
bool enableSemanticHighlighter)
|
||||||
: BaseEditorDocumentProcessor(document)
|
: BaseEditorDocumentProcessor(document)
|
||||||
, m_parser(document->filePath().toString())
|
, m_parser(new BuiltinEditorDocumentParser(document->filePath().toString()))
|
||||||
, m_codeWarningsUpdated(false)
|
, m_codeWarningsUpdated(false)
|
||||||
, m_semanticHighlighter(enableSemanticHighlighter
|
, m_semanticHighlighter(enableSemanticHighlighter
|
||||||
? new CppTools::SemanticHighlighter(document)
|
? new CppTools::SemanticHighlighter(document)
|
||||||
@@ -135,9 +135,9 @@ BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(
|
|||||||
|
|
||||||
QSharedPointer<CppCodeModelSettings> cms = CppToolsPlugin::instance()->codeModelSettings();
|
QSharedPointer<CppCodeModelSettings> cms = CppToolsPlugin::instance()->codeModelSettings();
|
||||||
|
|
||||||
BaseEditorDocumentParser::Configuration config = m_parser.configuration();
|
BaseEditorDocumentParser::Configuration config = m_parser->configuration();
|
||||||
config.usePrecompiledHeaders = cms->pchUsage() != CppCodeModelSettings::PchUse_None;
|
config.usePrecompiledHeaders = cms->pchUsage() != CppCodeModelSettings::PchUse_None;
|
||||||
m_parser.setConfiguration(config);
|
m_parser->setConfiguration(config);
|
||||||
|
|
||||||
if (m_semanticHighlighter) {
|
if (m_semanticHighlighter) {
|
||||||
m_semanticHighlighter->setHighlightingRunner(
|
m_semanticHighlighter->setHighlightingRunner(
|
||||||
@@ -152,7 +152,7 @@ BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(&m_parser, &BuiltinEditorDocumentParser::finished,
|
connect(m_parser.data(), &BuiltinEditorDocumentParser::finished,
|
||||||
this, &BuiltinEditorDocumentProcessor::onParserFinished);
|
this, &BuiltinEditorDocumentProcessor::onParserFinished);
|
||||||
connect(&m_semanticInfoUpdater, &SemanticInfoUpdater::updated,
|
connect(&m_semanticInfoUpdater, &SemanticInfoUpdater::updated,
|
||||||
this, &BuiltinEditorDocumentProcessor::onSemanticInfoUpdated);
|
this, &BuiltinEditorDocumentProcessor::onSemanticInfoUpdated);
|
||||||
@@ -171,14 +171,14 @@ void BuiltinEditorDocumentProcessor::run()
|
|||||||
BuiltinEditorDocumentParser::InMemoryInfo(false));
|
BuiltinEditorDocumentParser::InMemoryInfo(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseEditorDocumentParser *BuiltinEditorDocumentProcessor::parser()
|
BaseEditorDocumentParser::Ptr BuiltinEditorDocumentProcessor::parser()
|
||||||
{
|
{
|
||||||
return &m_parser;
|
return m_parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPlusPlus::Snapshot BuiltinEditorDocumentProcessor::snapshot()
|
CPlusPlus::Snapshot BuiltinEditorDocumentProcessor::snapshot()
|
||||||
{
|
{
|
||||||
return m_parser.snapshot();
|
return m_parser->snapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuiltinEditorDocumentProcessor::recalculateSemanticInfoDetached(bool force)
|
void BuiltinEditorDocumentProcessor::recalculateSemanticInfoDetached(bool force)
|
||||||
|
@@ -53,7 +53,7 @@ public:
|
|||||||
void recalculateSemanticInfoDetached(bool force) override;
|
void recalculateSemanticInfoDetached(bool force) override;
|
||||||
void semanticRehighlight() override;
|
void semanticRehighlight() override;
|
||||||
CppTools::SemanticInfo recalculateSemanticInfo() override;
|
CppTools::SemanticInfo recalculateSemanticInfo() override;
|
||||||
BaseEditorDocumentParser *parser() override;
|
BaseEditorDocumentParser::Ptr parser() override;
|
||||||
CPlusPlus::Snapshot snapshot() override;
|
CPlusPlus::Snapshot snapshot() override;
|
||||||
bool isParserRunning() const override;
|
bool isParserRunning() const override;
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ private:
|
|||||||
SemanticInfo::Source createSemanticInfoSource(bool force) const;
|
SemanticInfo::Source createSemanticInfoSource(bool force) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BuiltinEditorDocumentParser m_parser;
|
BuiltinEditorDocumentParser::Ptr m_parser;
|
||||||
QFuture<void> m_parserFuture;
|
QFuture<void> m_parserFuture;
|
||||||
|
|
||||||
CPlusPlus::Snapshot m_documentSnapshot;
|
CPlusPlus::Snapshot m_documentSnapshot;
|
||||||
|
@@ -426,13 +426,13 @@ AssistInterface *InternalCompletionAssistProvider::createAssistInterface(
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(textEditorWidget, return 0);
|
QTC_ASSERT(textEditorWidget, return 0);
|
||||||
|
|
||||||
CppModelManager *modelManager = CppModelManager::instance();
|
|
||||||
return new CppCompletionAssistInterface(filePath,
|
return new CppCompletionAssistInterface(filePath,
|
||||||
textEditorWidget,
|
textEditorWidget,
|
||||||
|
BuiltinEditorDocumentParser::get(filePath),
|
||||||
languageFeatures,
|
languageFeatures,
|
||||||
position,
|
position,
|
||||||
reason,
|
reason,
|
||||||
modelManager->workingCopy());
|
CppModelManager::instance()->workingCopy());
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------
|
// -----------------
|
||||||
@@ -2187,11 +2187,11 @@ void CppCompletionAssistInterface::getCppSpecifics() const
|
|||||||
return;
|
return;
|
||||||
m_gotCppSpecifics = true;
|
m_gotCppSpecifics = true;
|
||||||
|
|
||||||
if (BuiltinEditorDocumentParser *parser = BuiltinEditorDocumentParser::get(fileName())) {
|
if (m_parser) {
|
||||||
parser->update(BuiltinEditorDocumentParser::InMemoryInfo(false));
|
m_parser->update(BuiltinEditorDocumentParser::InMemoryInfo(false));
|
||||||
m_snapshot = parser->snapshot();
|
m_snapshot = m_parser->snapshot();
|
||||||
m_headerPaths = parser->headerPaths();
|
m_headerPaths = m_parser->headerPaths();
|
||||||
if (Document::Ptr document = parser->document())
|
if (Document::Ptr document = m_parser->document())
|
||||||
m_languageFeatures = document->languageFeatures();
|
m_languageFeatures = document->languageFeatures();
|
||||||
else
|
else
|
||||||
m_languageFeatures = LanguageFeatures::defaultFeatures();
|
m_languageFeatures = LanguageFeatures::defaultFeatures();
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#ifndef CPPCOMPLETIONASSIST_H
|
#ifndef CPPCOMPLETIONASSIST_H
|
||||||
#define CPPCOMPLETIONASSIST_H
|
#define CPPCOMPLETIONASSIST_H
|
||||||
|
|
||||||
|
#include "builtineditordocumentparser.h"
|
||||||
#include "cppcompletionassistprocessor.h"
|
#include "cppcompletionassistprocessor.h"
|
||||||
#include "cppcompletionassistprovider.h"
|
#include "cppcompletionassistprovider.h"
|
||||||
#include "cppmodelmanager.h"
|
#include "cppmodelmanager.h"
|
||||||
@@ -171,11 +172,13 @@ class CppCompletionAssistInterface : public TextEditor::AssistInterface
|
|||||||
public:
|
public:
|
||||||
CppCompletionAssistInterface(const QString &filePath,
|
CppCompletionAssistInterface(const QString &filePath,
|
||||||
const TextEditor::TextEditorWidget *textEditorWidget,
|
const TextEditor::TextEditorWidget *textEditorWidget,
|
||||||
|
BuiltinEditorDocumentParser::Ptr parser,
|
||||||
const CPlusPlus::LanguageFeatures &languageFeatures,
|
const CPlusPlus::LanguageFeatures &languageFeatures,
|
||||||
int position,
|
int position,
|
||||||
TextEditor::AssistReason reason,
|
TextEditor::AssistReason reason,
|
||||||
const WorkingCopy &workingCopy)
|
const WorkingCopy &workingCopy)
|
||||||
: TextEditor::AssistInterface(textEditorWidget->document(), position, filePath, reason)
|
: TextEditor::AssistInterface(textEditorWidget->document(), position, filePath, reason)
|
||||||
|
, m_parser(parser)
|
||||||
, m_gotCppSpecifics(false)
|
, m_gotCppSpecifics(false)
|
||||||
, m_workingCopy(workingCopy)
|
, m_workingCopy(workingCopy)
|
||||||
, m_languageFeatures(languageFeatures)
|
, m_languageFeatures(languageFeatures)
|
||||||
@@ -204,6 +207,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void getCppSpecifics() const;
|
void getCppSpecifics() const;
|
||||||
|
|
||||||
|
BuiltinEditorDocumentParser::Ptr m_parser;
|
||||||
mutable bool m_gotCppSpecifics;
|
mutable bool m_gotCppSpecifics;
|
||||||
WorkingCopy m_workingCopy;
|
WorkingCopy m_workingCopy;
|
||||||
mutable CPlusPlus::Snapshot m_snapshot;
|
mutable CPlusPlus::Snapshot m_snapshot;
|
||||||
|
@@ -910,7 +910,7 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
|
|||||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
|
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
|
||||||
QVERIFY(mm->isCppEditor(editor));
|
QVERIFY(mm->isCppEditor(editor));
|
||||||
|
|
||||||
auto *parser = BuiltinEditorDocumentParser::get(fileName);
|
auto parser = BuiltinEditorDocumentParser::get(fileName);
|
||||||
QVERIFY(parser);
|
QVERIFY(parser);
|
||||||
BaseEditorDocumentParser::Configuration config = parser->configuration();
|
BaseEditorDocumentParser::Configuration config = parser->configuration();
|
||||||
config.usePrecompiledHeaders = true;
|
config.usePrecompiledHeaders = true;
|
||||||
@@ -994,7 +994,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
|
|||||||
QVERIFY(mm->isCppEditor(editor));
|
QVERIFY(mm->isCppEditor(editor));
|
||||||
|
|
||||||
const QString filePath = editor->document()->filePath().toString();
|
const QString filePath = editor->document()->filePath().toString();
|
||||||
BaseEditorDocumentParser *parser = BaseEditorDocumentParser::get(filePath);
|
const auto parser = BaseEditorDocumentParser::get(filePath);
|
||||||
BaseEditorDocumentParser::Configuration config = parser->configuration();
|
BaseEditorDocumentParser::Configuration config = parser->configuration();
|
||||||
config.editorDefines = editorDefines.toUtf8();
|
config.editorDefines = editorDefines.toUtf8();
|
||||||
parser->setConfiguration(config);
|
parser->setConfiguration(config);
|
||||||
|
@@ -196,12 +196,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compare
|
// Compare
|
||||||
BuiltinEditorDocumentParser *cppDocumentParser = BuiltinEditorDocumentParser::get(cppFile);
|
const auto cppDocumentParser = BuiltinEditorDocumentParser::get(cppFile);
|
||||||
QVERIFY(cppDocumentParser);
|
QVERIFY(cppDocumentParser);
|
||||||
const Document::Ptr cppDocument = cppDocumentParser->document();
|
const Document::Ptr cppDocument = cppDocumentParser->document();
|
||||||
QVERIFY(checkDiagsnosticMessages(cppDocument));
|
QVERIFY(checkDiagsnosticMessages(cppDocument));
|
||||||
|
|
||||||
BuiltinEditorDocumentParser *hDocumentParser = BuiltinEditorDocumentParser::get(hFile);
|
const auto hDocumentParser = BuiltinEditorDocumentParser::get(hFile);
|
||||||
QVERIFY(hDocumentParser);
|
QVERIFY(hDocumentParser);
|
||||||
const Document::Ptr hDocument = hDocumentParser->document();
|
const Document::Ptr hDocument = hDocumentParser->document();
|
||||||
QVERIFY(checkDiagsnosticMessages(hDocument));
|
QVERIFY(checkDiagsnosticMessages(hDocument));
|
||||||
|
@@ -89,7 +89,6 @@ public:
|
|||||||
virtual bool eventFilter(QObject *o, QEvent *e);
|
virtual bool eventFilter(QObject *o, QEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void finalizeRequest();
|
|
||||||
void proposalComputed();
|
void proposalComputed();
|
||||||
void processProposalItem(AssistProposalItem *proposalItem);
|
void processProposalItem(AssistProposalItem *proposalItem);
|
||||||
void handlePrefixExpansion(const QString &newPrefix);
|
void handlePrefixExpansion(const QString &newPrefix);
|
||||||
@@ -251,7 +250,7 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
|
|||||||
connect(m_requestRunner, &ProcessorRunner::finished,
|
connect(m_requestRunner, &ProcessorRunner::finished,
|
||||||
this, &CodeAssistantPrivate::proposalComputed);
|
this, &CodeAssistantPrivate::proposalComputed);
|
||||||
connect(m_requestRunner, &ProcessorRunner::finished,
|
connect(m_requestRunner, &ProcessorRunner::finished,
|
||||||
this, &CodeAssistantPrivate::finalizeRequest);
|
m_requestRunner, &QObject::deleteLater);
|
||||||
connect(m_requestRunner, &ProcessorRunner::finished,
|
connect(m_requestRunner, &ProcessorRunner::finished,
|
||||||
q, &CodeAssistant::finished);
|
q, &CodeAssistant::finished);
|
||||||
assistInterface->prepareForAsyncUse();
|
assistInterface->prepareForAsyncUse();
|
||||||
@@ -383,12 +382,6 @@ void CodeAssistantPrivate::handlePrefixExpansion(const QString &newPrefix)
|
|||||||
notifyChange();
|
notifyChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeAssistantPrivate::finalizeRequest()
|
|
||||||
{
|
|
||||||
if (ProcessorRunner *runner = qobject_cast<ProcessorRunner *>(sender()))
|
|
||||||
delete runner;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CodeAssistantPrivate::finalizeProposal()
|
void CodeAssistantPrivate::finalizeProposal()
|
||||||
{
|
{
|
||||||
stopAutomaticProposalTimer();
|
stopAutomaticProposalTimer();
|
||||||
|
Reference in New Issue
Block a user