From f13d402b315ddba386fd2434724198ab1e6a5693 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 30 Mar 2021 10:33:09 +0200 Subject: [PATCH] LanguageClient: prevent multiple TextEditorWidget connections Change-Id: I97c7cb00bad898cc5f698bd3dcee23e44acfa9e2 Reviewed-by: Christian Stenger --- src/plugins/languageclient/client.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/languageclient/client.cpp b/src/plugins/languageclient/client.cpp index 3bbba9d2893..54e54cb3cfe 100644 --- a/src/plugins/languageclient/client.cpp +++ b/src/plugins/languageclient/client.cpp @@ -707,13 +707,14 @@ void Client::cursorPositionChanged(TextEditor::TextEditorWidget *widget) timer = new QTimer; timer->setSingleShot(true); m_documentHighlightsTimer.insert(widget, timer); - connect(timer, &QTimer::timeout, this, [this, widget]() { + auto connection = connect(widget, &QWidget::destroyed, this, [widget, this]() { + delete m_documentHighlightsTimer.take(widget); + }); + connect(timer, &QTimer::timeout, this, [this, widget, connection]() { + disconnect(connection); requestDocumentHighlights(widget); m_documentHighlightsTimer.take(widget)->deleteLater(); }); - connect(widget, &QWidget::destroyed, this, [widget, this]() { - delete m_documentHighlightsTimer.take(widget); - }); } const Id selectionsId(TextEditor::TextEditorWidget::CodeSemanticsSelection); const QList semanticSelections = widget->extraSelections(selectionsId);