forked from qt-creator/qt-creator
Nim: Avoid using sender()
Change-Id: If5c537569ff1477dde675038684c1964803e2a4d Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -80,8 +80,8 @@ public:
|
||||
|
||||
if (!suggest->isReady()) {
|
||||
m_interface = interface;
|
||||
QObject::connect(suggest, &Suggest::NimSuggest::readyChanged,
|
||||
this, &NimCompletionAssistProcessor::onNimSuggestReady);
|
||||
QObject::connect(suggest, &Suggest::NimSuggest::readyChanged, this,
|
||||
[this, suggest](bool ready) { onNimSuggestReady(suggest, ready); });
|
||||
} else {
|
||||
doPerform(interface, suggest);
|
||||
}
|
||||
@@ -96,13 +96,11 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void onNimSuggestReady(bool ready)
|
||||
void onNimSuggestReady(Suggest::NimSuggest *suggest, bool ready)
|
||||
{
|
||||
auto suggest = dynamic_cast<Suggest::NimSuggest *>(sender());
|
||||
QTC_ASSERT(suggest, return);
|
||||
QTC_ASSERT(m_interface, return);
|
||||
|
||||
if (!ready || !suggest) {
|
||||
if (!ready) {
|
||||
m_running = false;
|
||||
setAsyncProposalAvailable(nullptr);
|
||||
} else {
|
||||
|
@@ -93,12 +93,14 @@ void NimTextEditorWidget::findLinkAt(const QTextCursor &c, const Utils::LinkHand
|
||||
m_callback = processLinkCallback;
|
||||
m_request = std::move(request);
|
||||
|
||||
QObject::connect(m_request.get(), &NimSuggestClientRequest::finished, this, &NimTextEditorWidget::onFindLinkFinished);
|
||||
Suggest::NimSuggestClientRequest *req = m_request.get();
|
||||
connect(req, &NimSuggestClientRequest::finished,
|
||||
this, [this, req] { onFindLinkFinished(req); });
|
||||
}
|
||||
|
||||
void NimTextEditorWidget::onFindLinkFinished()
|
||||
void NimTextEditorWidget::onFindLinkFinished(Suggest::NimSuggestClientRequest *request)
|
||||
{
|
||||
QTC_ASSERT(m_request.get() == this->sender(), return);
|
||||
QTC_ASSERT(m_request.get() == request, return);
|
||||
if (m_request->lines().empty()) {
|
||||
m_callback(Utils::Link());
|
||||
return;
|
||||
|
@@ -36,10 +36,11 @@ public:
|
||||
NimTextEditorWidget(QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
void findLinkAt(const QTextCursor &, const Utils::LinkHandler &processLinkCallback, bool resolveTarget, bool inNextSplit);
|
||||
void findLinkAt(const QTextCursor &, const Utils::LinkHandler &processLinkCallback,
|
||||
bool resolveTarget, bool inNextSplit);
|
||||
|
||||
private:
|
||||
void onFindLinkFinished();
|
||||
void onFindLinkFinished(Suggest::NimSuggestClientRequest *request);
|
||||
|
||||
std::shared_ptr<Nim::Suggest::NimSuggestClientRequest> m_request;
|
||||
Utils::LinkHandler m_callback;
|
||||
|
Reference in New Issue
Block a user