Clang: Abort hover handlers on ~TextEditorWidget

We have a QPointer<QTextEditorWidget> 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 <orgads@gmail.com>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Nikolai Kosjar
2018-11-26 16:10:20 +01:00
parent d47cb48909
commit 03ee0e6acc

View File

@@ -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<TextEditorWidget> m_widget;
void abortHandlers()
{
for (BaseHoverHandler *handler : m_handlers)
handler->abort();
}
TextEditorWidget *m_widget;
const QList<BaseHoverHandler *> &m_handlers;
struct LastHandlerInfo {