aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cpptools/cppcompletionassist.h
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2015-09-01 17:34:07 +0200
committerNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2015-09-02 12:37:23 +0000
commit169556db2f63912b7eaa2375dbc17c52ffd57586 (patch)
treec2a4a979dfbdabc6c2d93a24e038a15b19f8bab5 /src/plugins/cpptools/cppcompletionassist.h
parentc504e56d0c7fafba4f8c15997e3927b5ca02adc5 (diff)
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>
Diffstat (limited to 'src/plugins/cpptools/cppcompletionassist.h')
-rw-r--r--src/plugins/cpptools/cppcompletionassist.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppcompletionassist.h b/src/plugins/cpptools/cppcompletionassist.h
index 9de04d69e4..01fd44e5b8 100644
--- a/src/plugins/cpptools/cppcompletionassist.h
+++ b/src/plugins/cpptools/cppcompletionassist.h
@@ -31,6 +31,7 @@
#ifndef CPPCOMPLETIONASSIST_H
#define CPPCOMPLETIONASSIST_H
+#include "builtineditordocumentparser.h"
#include "cppcompletionassistprocessor.h"
#include "cppcompletionassistprovider.h"
#include "cppmodelmanager.h"
@@ -171,11 +172,13 @@ class CppCompletionAssistInterface : public TextEditor::AssistInterface
public:
CppCompletionAssistInterface(const QString &filePath,
const TextEditor::TextEditorWidget *textEditorWidget,
+ BuiltinEditorDocumentParser::Ptr parser,
const CPlusPlus::LanguageFeatures &languageFeatures,
int position,
TextEditor::AssistReason reason,
const WorkingCopy &workingCopy)
: TextEditor::AssistInterface(textEditorWidget->document(), position, filePath, reason)
+ , m_parser(parser)
, m_gotCppSpecifics(false)
, m_workingCopy(workingCopy)
, m_languageFeatures(languageFeatures)
@@ -204,6 +207,7 @@ public:
private:
void getCppSpecifics() const;
+ BuiltinEditorDocumentParser::Ptr m_parser;
mutable bool m_gotCppSpecifics;
WorkingCopy m_workingCopy;
mutable CPlusPlus::Snapshot m_snapshot;