From e6e895d6beea5e7676ac6783003d49e560f49963 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 24 Mar 2023 11:27:21 +0100 Subject: [PATCH] Copilot: correctly cleanup compression timer fixes a leak and a crash if the timer triggers after the widget was deleted. Change-Id: I57794009186d4c5e4dee0b0c0746ffc5468000b7 Reviewed-by: Artem Sokolovskii Reviewed-by: Marcus Tillmanns --- src/plugins/copilot/copilotclient.cpp | 5 +++++ src/plugins/copilot/copilotclient.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/plugins/copilot/copilotclient.cpp b/src/plugins/copilot/copilotclient.cpp index 50be6788410..e1122020926 100644 --- a/src/plugins/copilot/copilotclient.cpp +++ b/src/plugins/copilot/copilotclient.cpp @@ -108,6 +108,11 @@ void CopilotClient::scheduleRequest(TextEditorWidget *editor) m_scheduledRequests[editor].timer->start(500); } +CopilotClient::ScheduleData::~ScheduleData() +{ + delete timer; +} + void CopilotClient::requestCompletions(TextEditorWidget *editor) { Utils::MultiTextCursor cursor = editor->multiTextCursor(); diff --git a/src/plugins/copilot/copilotclient.h b/src/plugins/copilot/copilotclient.h index 5111e04e1df..e29343f3680 100644 --- a/src/plugins/copilot/copilotclient.h +++ b/src/plugins/copilot/copilotclient.h @@ -50,6 +50,7 @@ private: QMap m_runningRequests; struct ScheduleData { + ~ScheduleData(); int cursorPosition = -1; QTimer *timer = nullptr; };