mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-28 19:40:54 +00:00
Fix possible crashes in toastParent expiring.
This commit is contained in:
parent
6f50906952
commit
cfddca8f58
@ -110,7 +110,9 @@ void SendBotCallbackData(
|
||||
const auto showAlert = data.is_alert();
|
||||
|
||||
if (!message.isEmpty()) {
|
||||
if (showAlert) {
|
||||
if (!show->valid()) {
|
||||
return;
|
||||
} else if (showAlert) {
|
||||
show->showBox(Ui::MakeInformBox(message));
|
||||
} else {
|
||||
if (withPassword) {
|
||||
|
@ -44,9 +44,10 @@ void SendReport(
|
||||
Ui::ReportReason reason,
|
||||
const QString &comment,
|
||||
std::variant<v::null_t, MessageIdsList, not_null<PhotoData*>> data) {
|
||||
auto done = [=] {
|
||||
auto weak = Ui::MakeWeak(toastParent.get());
|
||||
auto done = crl::guard(toastParent, [=] {
|
||||
Ui::Toast::Show(toastParent, tr::lng_report_thanks(tr::now));
|
||||
};
|
||||
});
|
||||
v::match(data, [&](v::null_t) {
|
||||
peer->session().api().request(MTPaccount_ReportPeer(
|
||||
peer->input,
|
||||
|
@ -622,21 +622,21 @@ void EditAdminBox::sendTransferRequestFrom(
|
||||
channel->inputChannel,
|
||||
user->inputUser,
|
||||
result.result
|
||||
)).done([=, toastParent = _show.toastParent()](const MTPUpdates &result) {
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
api->applyUpdates(result);
|
||||
if (!box && !weak) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ui::Toast::Show(
|
||||
toastParent,
|
||||
(box ? Ui::BoxShow(box) : weak->_show).toastParent(),
|
||||
(channel->isBroadcast()
|
||||
? tr::lng_rights_transfer_done_channel
|
||||
: tr::lng_rights_transfer_done_group)(
|
||||
tr::now,
|
||||
lt_user,
|
||||
user->shortName()));
|
||||
if (box) {
|
||||
Ui::BoxShow(box).hideLayer();
|
||||
} else if (weak) {
|
||||
weak->_show.hideLayer();
|
||||
}
|
||||
(box ? Ui::BoxShow(box) : weak->_show).hideLayer();
|
||||
}).fail(crl::guard(this, [=](const MTP::Error &error) {
|
||||
if (weak) {
|
||||
_transferRequestId = 0;
|
||||
|
@ -1438,6 +1438,7 @@ void StickerSetBox::Inner::install() {
|
||||
}
|
||||
|
||||
void StickerSetBox::Inner::archiveStickers() {
|
||||
const auto toastParent = Window::Show(_controller).toastParent();
|
||||
_api.request(MTPmessages_InstallStickerSet(
|
||||
Data::InputStickerSet(_input),
|
||||
MTP_boolTrue()
|
||||
@ -1445,9 +1446,9 @@ void StickerSetBox::Inner::archiveStickers() {
|
||||
if (result.type() == mtpc_messages_stickerSetInstallResultSuccess) {
|
||||
_setArchived.fire_copy(_setId);
|
||||
}
|
||||
}).fail([toastParent = Window::Show(_controller).toastParent()] {
|
||||
}).fail(crl::guard(toastParent, [=] {
|
||||
Ui::Toast::Show(toastParent, Lang::Hard::ServerError());
|
||||
}).send();
|
||||
})).send();
|
||||
}
|
||||
|
||||
void StickerSetBox::Inner::updateItems() {
|
||||
|
@ -1209,11 +1209,11 @@ void AddSaveSoundForNotifications(
|
||||
Api::ToggleSavedRingtone(
|
||||
document,
|
||||
item->fullId(),
|
||||
[=] {
|
||||
crl::guard(toastParent, [=] {
|
||||
Ui::Toast::Show(
|
||||
toastParent,
|
||||
tr::lng_ringtones_toast_added(tr::now));
|
||||
},
|
||||
}),
|
||||
true);
|
||||
}, &st::menuIconSoundAdd);
|
||||
}
|
||||
|
@ -202,7 +202,6 @@ void TTLBox(not_null<Ui::GenericBox*> box, Args args) {
|
||||
if (args.startTtl && !args.hideDisable) {
|
||||
box->addLeftButton(tr::lng_manage_messages_ttl_disable(), [=] {
|
||||
args.callback(0, [=] { box->closeBox(); });
|
||||
box->getDelegate()->hideLayer();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ Args TTLValidator::createArgs() const {
|
||||
mtpRequestId savingRequestId = 0;
|
||||
};
|
||||
const auto state = std::make_shared<State>();
|
||||
auto callback = [=, toastParent = show->toastParent()](
|
||||
auto callback = [=](
|
||||
TimeId period,
|
||||
Fn<void()>) {
|
||||
auto &api = peer->session().api();
|
||||
@ -79,12 +79,15 @@ Args TTLValidator::createArgs() const {
|
||||
api.request(state->savingRequestId).cancel();
|
||||
}
|
||||
state->savingPeriod = period;
|
||||
const auto weak = Ui::MakeWeak(show->toastParent().get());
|
||||
state->savingRequestId = api.request(MTPmessages_SetHistoryTTL(
|
||||
peer->input,
|
||||
MTP_int(period)
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
peer->session().api().applyUpdates(result);
|
||||
ShowAutoDeleteToast(toastParent, peer);
|
||||
if (const auto strong = weak.data()) {
|
||||
ShowAutoDeleteToast(strong, peer);
|
||||
}
|
||||
state->savingRequestId = 0;
|
||||
}).fail([=] {
|
||||
state->savingRequestId = 0;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit d5921e742fa9f17f65a25091a184f5a8a72ea779
|
||||
Subproject commit 580e6a561f7d252a94888b54c206e06ac0237c38
|
Loading…
Reference in New Issue
Block a user