summaryrefslogtreecommitdiff
path: root/src/plugins/clangcodemodel
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@qt.io>2017-07-14 09:42:05 +0200
committerNikolai Kosjar <nikolai.kosjar@qt.io>2017-07-17 08:24:08 +0000
commit8309e0c56a234f7ab1c2d658fcd680b801a5e2f4 (patch)
tree992ab9e9fd3f6fcbe40515c447962a133d594c1c /src/plugins/clangcodemodel
parentdb88225b0ea9531062d184f2e52492b3218980f3 (diff)
downloadqt-creator-8309e0c56a234f7ab1c2d658fcd680b801a5e2f4.tar.gz
Clang: Avoid blocking UI if references are requested and clangbackend crashes
The two cases in which the UI might be blocked are: * Invocation of the editor context menu * Rename Symbol Under Cursor Cancel the future if the backend is restarted and on the other side, check whether the future is cancelled. Change-Id: If2315da1f66f15eab1531fcd8da1dff851a9a4e6 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/clangcodemodel')
-rw-r--r--src/plugins/clangcodemodel/clangbackendipcintegration.cpp22
-rw-r--r--src/plugins/clangcodemodel/clangbackendipcintegration.h4
2 files changed, 16 insertions, 10 deletions
diff --git a/src/plugins/clangcodemodel/clangbackendipcintegration.cpp b/src/plugins/clangcodemodel/clangbackendipcintegration.cpp
index 5ff5b1aa7e..cfb52f1528 100644
--- a/src/plugins/clangcodemodel/clangbackendipcintegration.cpp
+++ b/src/plugins/clangcodemodel/clangbackendipcintegration.cpp
@@ -99,7 +99,7 @@ IpcReceiver::IpcReceiver()
IpcReceiver::~IpcReceiver()
{
- deleteAndClearWaitingAssistProcessors();
+ reset();
}
void IpcReceiver::setAliveHandler(const IpcReceiver::AliveHandler &handler)
@@ -116,12 +116,6 @@ void IpcReceiver::addExpectedCodeCompletedMessage(
m_assistProcessorsTable.insert(ticket, processor);
}
-void IpcReceiver::deleteAndClearWaitingAssistProcessors()
-{
- qDeleteAll(m_assistProcessorsTable.begin(), m_assistProcessorsTable.end());
- m_assistProcessorsTable.clear();
-}
-
void IpcReceiver::deleteProcessorsOfEditorWidget(TextEditor::TextEditorWidget *textEditorWidget)
{
QMutableHashIterator<quint64, ClangCompletionAssistProcessor *> it(m_assistProcessorsTable);
@@ -155,6 +149,18 @@ bool IpcReceiver::isExpectingCodeCompletedMessage() const
return !m_assistProcessorsTable.isEmpty();
}
+void IpcReceiver::reset()
+{
+ // Clean up waiting assist processors
+ qDeleteAll(m_assistProcessorsTable.begin(), m_assistProcessorsTable.end());
+ m_assistProcessorsTable.clear();
+
+ // Clean up futures for references
+ for (ReferencesEntry &entry : m_referencesTable)
+ entry.futureInterface.cancel();
+ m_referencesTable.clear();
+}
+
void IpcReceiver::alive()
{
if (printAliveMessage())
@@ -719,7 +725,7 @@ void IpcCommunicator::onConnectedToBackend()
if (m_connectedCount > 1)
logRestartedDueToUnexpectedFinish();
- m_ipcReceiver.deleteAndClearWaitingAssistProcessors();
+ m_ipcReceiver.reset();
m_ipcSender.reset(new IpcSender(m_connection));
initializeBackendWithCurrentData();
diff --git a/src/plugins/clangcodemodel/clangbackendipcintegration.h b/src/plugins/clangcodemodel/clangbackendipcintegration.h
index 57a07e8097..e98565f48c 100644
--- a/src/plugins/clangcodemodel/clangbackendipcintegration.h
+++ b/src/plugins/clangcodemodel/clangbackendipcintegration.h
@@ -73,14 +73,14 @@ public:
void setAliveHandler(const AliveHandler &handler);
void addExpectedCodeCompletedMessage(quint64 ticket, ClangCompletionAssistProcessor *processor);
- void deleteAndClearWaitingAssistProcessors();
void deleteProcessorsOfEditorWidget(TextEditor::TextEditorWidget *textEditorWidget);
QFuture<CppTools::CursorInfo> addExpectedReferencesMessage(quint64 ticket,
QTextDocument *textDocument);
-
bool isExpectingCodeCompletedMessage() const;
+ void reset();
+
private:
void alive() override;
void echo(const ClangBackEnd::EchoMessage &message) override;