diff --git a/Telegram/SourceFiles/info/profile/info_profile_emoji_status_panel.cpp b/Telegram/SourceFiles/info/profile/info_profile_emoji_status_panel.cpp index 5b48b9415..c65c4cf40 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_emoji_status_panel.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_emoji_status_panel.cpp @@ -62,10 +62,6 @@ void EmojiStatusPanel::setChooseFilter(Fn filter) { _chooseFilter = std::move(filter); } -void EmojiStatusPanel::setChooseCallback(Fn callback) { - _chooseCallback = std::move(callback); -} - void EmojiStatusPanel::show( not_null controller, not_null button, @@ -173,16 +169,16 @@ void EmojiStatusPanel::create( return Chosen{ .animation = data.messageSendingFrom }; }); + const auto weak = Ui::MakeWeak(_panel.get()); const auto accept = [=](Chosen chosen) { Expects(chosen.until != Selector::kPickCustomTimeId); + // From PickUntilBox is called after EmojiStatusPanel is destroyed! const auto owner = &controller->session().data(); - startAnimation(owner, body, chosen.id, chosen.animation); - if (_chooseCallback) { - _chooseCallback(chosen.id); - } else { - owner->emojiStatuses().set(chosen.id, chosen.until); + if (weak) { + startAnimation(owner, body, chosen.id, chosen.animation); } + owner->emojiStatuses().set(chosen.id, chosen.until); }; rpl::merge( diff --git a/Telegram/SourceFiles/info/profile/info_profile_emoji_status_panel.h b/Telegram/SourceFiles/info/profile/info_profile_emoji_status_panel.h index a1acf5556..3d4373665 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_emoji_status_panel.h +++ b/Telegram/SourceFiles/info/profile/info_profile_emoji_status_panel.h @@ -41,7 +41,6 @@ public: ~EmojiStatusPanel(); void setChooseFilter(Fn filter); - void setChooseCallback(Fn callback); void show( not_null controller, @@ -64,7 +63,6 @@ private: base::unique_qptr _panel; Fn _chooseFilter; - Fn _chooseCallback; QPointer _panelButton; std::unique_ptr _animation; Data::CustomEmojiSizeTag _animationSizeTag = {};