forked from qt-creator/qt-creator
CppEditor: Cancel runner in ~CppUseSelectionsUpdater
...otherwise an already destructed QTextDocument might be accessed in the ClangCodeModel::Internal::IpcReceiver::references. Task-number: QTCREATORBUG-18459 Change-Id: I1868b2fd3a64341794f83eea6c4eeb7c2c1af812 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -248,9 +248,9 @@ void IpcReceiver::references(const ReferencesMessage &message)
|
||||
QTC_CHECK(futureInterface != QFutureInterface<CppTools::CursorInfo>());
|
||||
|
||||
if (futureInterface.isCanceled())
|
||||
return; // A new request was issued making this one outdated.
|
||||
return; // Editor document closed or a new request was issued making this result outdated.
|
||||
|
||||
QTC_CHECK(entry.textDocument);
|
||||
QTC_ASSERT(entry.textDocument, return);
|
||||
futureInterface.reportResult(toCursorInfo(*entry.textDocument, message));
|
||||
futureInterface.reportFinished();
|
||||
}
|
||||
|
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <QFuture>
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QSharedPointer>
|
||||
#include <QTextDocument>
|
||||
#include <QVector>
|
||||
@@ -102,7 +103,7 @@ private:
|
||||
: futureInterface(futureInterface)
|
||||
, textDocument(textDocument) {}
|
||||
QFutureInterface<CppTools::CursorInfo> futureInterface;
|
||||
QTextDocument *textDocument = nullptr;
|
||||
QPointer<QTextDocument> textDocument;
|
||||
};
|
||||
QHash<quint64, ReferencesEntry> m_referencesTable;
|
||||
};
|
||||
|
@@ -49,6 +49,12 @@ CppUseSelectionsUpdater::CppUseSelectionsUpdater(TextEditor::TextEditorWidget *e
|
||||
connect(&m_timer, &QTimer::timeout, this, [this]() { update(); });
|
||||
}
|
||||
|
||||
CppUseSelectionsUpdater::~CppUseSelectionsUpdater()
|
||||
{
|
||||
if (m_runnerWatcher)
|
||||
m_runnerWatcher->cancel();
|
||||
}
|
||||
|
||||
void CppUseSelectionsUpdater::scheduleUpdate()
|
||||
{
|
||||
m_timer.start();
|
||||
|
@@ -44,6 +44,7 @@ class CppUseSelectionsUpdater : public QObject
|
||||
|
||||
public:
|
||||
explicit CppUseSelectionsUpdater(TextEditor::TextEditorWidget *editorWidget);
|
||||
~CppUseSelectionsUpdater();
|
||||
|
||||
void scheduleUpdate();
|
||||
void abortSchedule();
|
||||
|
Reference in New Issue
Block a user