2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Fixed memory leak from bar of pinned messages.

This commit is contained in:
23rd
2022-10-18 04:10:23 +03:00
committed by John Preston
parent a4856e4436
commit 659a7622be

View File

@@ -84,13 +84,13 @@ void PinnedBar::setContent(rpl::producer<Ui::MessageBarContent> content) {
void PinnedBar::setRightButton(object_ptr<Ui::RpWidget> button) {
const auto hasPrevious = (_right.button != nullptr);
if (auto previous = _right.button.release()) {
_right.previousButtonLifetime.make_state<RightButton>(
RightButton::fromRaw(std::move(previous)));
_right.previousButtonLifetime = previous->toggledValue(
using Unique = base::unique_qptr<Ui::FadeWrapScaled<Ui::RpWidget>>;
_right.previousButtonLifetime = previous->shownValue(
) | rpl::filter(!rpl::mappers::_1) | rpl::start_with_next([=] {
_right.previousButtonLifetime.destroy();
});
previous->hide(anim::type::normal);
_right.previousButtonLifetime.make_state<Unique>(Unique{ previous });
}
_right.button.create(_wrap.entity(), std::move(button));
if (_right.button) {