CodeAssist: Fix leaking asynchronous processors

Currently the ownership of the processor is unknown to the codeassist
when running an async operation. Move the ownership of the processor to
the assist and delete the processor after the proposal was completed.

Change-Id: I6a2e023c47cbc876669dba866bee12b481447cb7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2020-03-26 09:21:57 +01:00
parent da3b14faee
commit 8bde432dfe
7 changed files with 36 additions and 5 deletions

View File

@@ -40,6 +40,7 @@
#include <projectexplorer/project.h>
#include <projectexplorer/session.h>
#include <texteditor/codeassist/documentcontentcompletion.h>
#include <texteditor/codeassist/iassistprocessor.h>
#include <texteditor/syntaxhighlighter.h>
#include <texteditor/tabsettings.h>
#include <texteditor/textdocument.h>
@@ -146,6 +147,8 @@ Client::~Client()
highlighter->clearAllExtraFormats();
}
}
for (IAssistProcessor *processor : m_runningAssistProcessors)
processor->setAsyncProposalAvailable(nullptr);
updateEditorToolBar(m_openedDocument.keys());
}
@@ -902,6 +905,16 @@ bool Client::isSupportedUri(const DocumentUri &uri) const
Utils::mimeTypeForFile(uri.toFilePath().fileName()).name());
}
void Client::addAssistProcessor(TextEditor::IAssistProcessor *processor)
{
m_runningAssistProcessors.insert(processor);
}
void Client::removeAssistProcessor(TextEditor::IAssistProcessor *processor)
{
m_runningAssistProcessors.remove(processor);
}
bool Client::needsRestart(const BaseSettings *settings) const
{
QTC_ASSERT(settings, return false);
@@ -942,6 +955,9 @@ bool Client::reset()
document->disconnect(this);
for (TextEditor::TextDocument *document : m_resetAssistProvider.keys())
resetAssistProviders(document);
for (TextEditor::IAssistProcessor *processor : m_runningAssistProcessors)
processor->setAsyncProposalAvailable(nullptr);
m_runningAssistProcessors.clear();
return true;
}