You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 12, 2023. It is now read-only.
Considering this situation: Display a dialog, and then use AsyncFuture to send a network request, and the result will be displayed on the interface when the network request responds. I used the following logic (pseudo code):
Dialog::request()
{
auto future = ... ; // request data from networkobserve(future).subscribe([=](QString data){ // onComplete
ui->label->setText(data);
},
[=](){ // onCanceled
ui->errorLabel->setText("error");
});
}
But before the network reply, the user may close the dialog. In this case, the ui->label in onComplete has been destroyed, causing a crash.
Is there any plan to add contextObject to function subscribe? So I can modify code like this
Dialog::request()
{
auto future = ... ; // request data from network
- observe(future).subscribe([=](QString data){ // onComplete+ observe(future).subscribe(this, [=](QString data){ // onComplete
ui->label->setText(data);
},
[=](){ // onCanceled
ui->errorLabel->setText("error");
});
}
Considering this situation: Display a dialog, and then use
AsyncFutureto send a network request, and the result will be displayed on the interface when the network request responds. I used the following logic (pseudo code):But before the network reply, the user may close the dialog. In this case, the
ui->labelin onComplete has been destroyed, causing a crash.Is there any plan to add
contextObjectto functionsubscribe? So I can modify code like thisDialog::request() { auto future = ... ; // request data from network - observe(future).subscribe([=](QString data){ // onComplete + observe(future).subscribe(this, [=](QString data){ // onComplete ui->label->setText(data); }, [=](){ // onCanceled ui->errorLabel->setText("error"); }); }