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);