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()) {
|
if (!suggest->isReady()) {
|
||||||
m_interface = interface;
|
m_interface = interface;
|
||||||
QObject::connect(suggest, &Suggest::NimSuggest::readyChanged,
|
QObject::connect(suggest, &Suggest::NimSuggest::readyChanged, this,
|
||||||
this, &NimCompletionAssistProcessor::onNimSuggestReady);
|
[this, suggest](bool ready) { onNimSuggestReady(suggest, ready); });
|
||||||
} else {
|
} else {
|
||||||
doPerform(interface, suggest);
|
doPerform(interface, suggest);
|
||||||
}
|
}
|
||||||
@@ -96,13 +96,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
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);
|
QTC_ASSERT(m_interface, return);
|
||||||
|
|
||||||
if (!ready || !suggest) {
|
if (!ready) {
|
||||||
m_running = false;
|
m_running = false;
|
||||||
setAsyncProposalAvailable(nullptr);
|
setAsyncProposalAvailable(nullptr);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -93,12 +93,14 @@ void NimTextEditorWidget::findLinkAt(const QTextCursor &c, const Utils::LinkHand
|
|||||||
m_callback = processLinkCallback;
|
m_callback = processLinkCallback;
|
||||||
m_request = std::move(request);
|
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()) {
|
if (m_request->lines().empty()) {
|
||||||
m_callback(Utils::Link());
|
m_callback(Utils::Link());
|
||||||
return;
|
return;
|
||||||
|
@@ -36,10 +36,11 @@ public:
|
|||||||
NimTextEditorWidget(QWidget* parent = nullptr);
|
NimTextEditorWidget(QWidget* parent = nullptr);
|
||||||
|
|
||||||
protected:
|
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:
|
private:
|
||||||
void onFindLinkFinished();
|
void onFindLinkFinished(Suggest::NimSuggestClientRequest *request);
|
||||||
|
|
||||||
std::shared_ptr<Nim::Suggest::NimSuggestClientRequest> m_request;
|
std::shared_ptr<Nim::Suggest::NimSuggestClientRequest> m_request;
|
||||||
Utils::LinkHandler m_callback;
|
Utils::LinkHandler m_callback;
|
||||||
|
Reference in New Issue
Block a user