From 03ee0e6acc6ae2bb5afba698ef333db3ea36af97 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Mon, 26 Nov 2018 16:10:20 +0100 Subject: [PATCH] Clang: Abort hover handlers on ~TextEditorWidget We have a QPointer in HoverHandlerRunner and a check in onHandlerFinished() to handle the editor-closed-case. However, the HoverHandlerRunner and thus the QPointer<> do not outlive the TextEditorWidget. Abort the handlers in ~HoverHandlerRunner instead. Task-number: QTCREATORBUG-21582 Change-Id: I03b78802ca75ddd4be9fea994e3dd9b152060e72 Reviewed-by: Orgad Shaneh Reviewed-by: David Schulz --- src/plugins/texteditor/texteditor.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index f4d141af6a4..47beba57068 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -299,6 +299,8 @@ public: { } + ~HoverHandlerRunner() { abortHandlers(); } + void startChecking(const QTextCursor &textCursor, const QPoint &point) { if (m_handlers.empty()) @@ -315,9 +317,7 @@ public: if (isCheckRunning(documentRevision, position)) return; - // Cancel currently running checks - for (BaseHoverHandler *handler : m_handlers) - handler->abort(); + abortHandlers(); // Update invocation data m_documentRevision = documentRevision; @@ -352,8 +352,6 @@ public: void onHandlerFinished(int documentRevision, int position, int priority) { - if (!m_widget) - return; QTC_ASSERT(m_currentHandlerIndex < m_handlers.size(), return); QTC_ASSERT(documentRevision == m_documentRevision, return); QTC_ASSERT(position == m_position, return); @@ -379,7 +377,13 @@ public: } private: - QPointer m_widget; + void abortHandlers() + { + for (BaseHoverHandler *handler : m_handlers) + handler->abort(); + } + + TextEditorWidget *m_widget; const QList &m_handlers; struct LastHandlerInfo {