mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Fix possible crash in members invite.
In some cases Info::Controller (public Window::SessionNavigation) can be destroyed without the box being destroyed, for example when group topics are turned on and off.
This commit is contained in:
parent
1cb0d7c2dc
commit
9d3715a36a
1 changed files with 11 additions and 6 deletions
|
@ -295,10 +295,11 @@ void AddParticipantsBoxController::Start(
|
|||
not_null<ChatData*> chat) {
|
||||
auto controller = std::make_unique<AddParticipantsBoxController>(chat);
|
||||
const auto weak = controller.get();
|
||||
const auto parent = navigation->parentController();
|
||||
auto initBox = [=](not_null<PeerListBox*> box) {
|
||||
box->addButton(tr::lng_participant_invite(), [=] {
|
||||
weak->inviteSelectedUsers(box, [=] {
|
||||
navigation->parentController()->showPeerHistory(
|
||||
parent->showPeerHistory(
|
||||
chat,
|
||||
Window::SectionShow::Way::ClearStack,
|
||||
ShowAtTheEndMsgId);
|
||||
|
@ -320,11 +321,12 @@ void AddParticipantsBoxController::Start(
|
|||
channel,
|
||||
std::move(alreadyIn));
|
||||
const auto weak = controller.get();
|
||||
const auto parent = navigation->parentController();
|
||||
auto initBox = [=](not_null<PeerListBox*> box) {
|
||||
box->addButton(tr::lng_participant_invite(), [=] {
|
||||
weak->inviteSelectedUsers(box, [=] {
|
||||
if (channel->isMegagroup()) {
|
||||
navigation->parentController()->showPeerHistory(
|
||||
parent->showPeerHistory(
|
||||
channel,
|
||||
Window::SectionShow::Way::ClearStack,
|
||||
ShowAtTheEndMsgId);
|
||||
|
@ -337,13 +339,16 @@ void AddParticipantsBoxController::Start(
|
|||
justCreated ? tr::lng_create_group_skip() : tr::lng_cancel(),
|
||||
[=] { box->closeBox(); });
|
||||
if (justCreated) {
|
||||
const auto weak = base::make_weak(parent);
|
||||
box->boxClosing() | rpl::start_with_next([=] {
|
||||
auto params = Window::SectionShow();
|
||||
params.activation = anim::activation::background;
|
||||
navigation->parentController()->showPeerHistory(
|
||||
channel,
|
||||
params,
|
||||
ShowAtTheEndMsgId);
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->showPeerHistory(
|
||||
channel,
|
||||
params,
|
||||
ShowAtTheEndMsgId);
|
||||
}
|
||||
}, box->lifetime());
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue