From dd3ba874b4538c698c6e8c43145bd196452a57a8 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Fri, 3 Feb 2017 11:41:26 +0100 Subject: [PATCH] CppEditor: Disconnect lambdas Otherwise this can lead to use-after-free access, as in: 1. Open a document 2. Duplicate it the editor 3. Close current editor 4. Modify the preprocessor directives ('#' button) Change-Id: I3032dbbfac86ad86e08dc39e85703bc176a27ca2 Reviewed-by: David Schulz --- src/plugins/cppeditor/cppeditor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index a2c73661ff3..54b3d5fa3ef 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -184,7 +184,7 @@ void CppEditorWidget::finalizeInitialization() &d->m_localRenaming, &CppLocalRenaming::updateSelectionsForVariableUnderCursor); - connect(&d->m_useSelectionsUpdater, &CppUseSelectionsUpdater::finished, + connect(&d->m_useSelectionsUpdater, &CppUseSelectionsUpdater::finished, this, [this] (SemanticInfo::LocalUseMap localUses) { QTC_CHECK(isSemanticInfoValidExceptLocalUses()); d->m_lastSemanticInfo.localUsesUpdated = true; @@ -201,7 +201,7 @@ void CppEditorWidget::finalizeInitialization() connect(this, &QPlainTextEdit::cursorPositionChanged, d->m_cppEditorOutline, &CppEditorOutline::updateIndex); - connect(cppEditorDocument(), &CppEditorDocument::preprocessorSettingsChanged, + connect(cppEditorDocument(), &CppEditorDocument::preprocessorSettingsChanged, this, [this](bool customSettings) { d->m_preprocessorButton->setProperty("highlightWidget", customSettings); d->m_preprocessorButton->update(); @@ -216,7 +216,7 @@ void CppEditorWidget::finalizeInitialization() connect(this, &QPlainTextEdit::textChanged, this, &CppEditorWidget::updateFunctionDeclDefLink); // set up the use highlighitng - connect(this, &CppEditorWidget::cursorPositionChanged, [this]() { + connect(this, &CppEditorWidget::cursorPositionChanged, this, [this]() { if (!d->m_localRenaming.isActive()) d->m_useSelectionsUpdater.scheduleUpdate();