From 7fb99319bb33ce6167e1a5f069cc4ab9a25489bd Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 23 May 2022 14:35:39 +0400 Subject: [PATCH] Fix repeated subscriptions on layer wrapping type change. --- Telegram/SourceFiles/info/info_layer_widget.cpp | 2 +- Telegram/SourceFiles/info/info_section_widget.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/info/info_layer_widget.cpp b/Telegram/SourceFiles/info/info_layer_widget.cpp index f170c690f3..b2f081cb81 100644 --- a/Telegram/SourceFiles/info/info_layer_widget.cpp +++ b/Telegram/SourceFiles/info/info_layer_widget.cpp @@ -244,7 +244,7 @@ int LayerWidget::MinimalSupportedWidth() { } int LayerWidget::resizeGetHeight(int newWidth) { - if (!parentWidget() || !_content) { + if (!parentWidget() || !_content || !newWidth) { return 0; } constexpr auto kMaxAttempts = 16; diff --git a/Telegram/SourceFiles/info/info_section_widget.cpp b/Telegram/SourceFiles/info/info_section_widget.cpp index 75d0b2dd85..c8d6fd3fdb 100644 --- a/Telegram/SourceFiles/info/info_section_widget.cpp +++ b/Telegram/SourceFiles/info/info_section_widget.cpp @@ -46,14 +46,16 @@ void SectionWidget::init() { rpl::combine( sizeValue(), _content->desiredHeightValue() - ) | rpl::start_with_next([wrap = _content.data()](QSize size, int) { + ) | rpl::filter([=] { + return (_content != nullptr); + }) | rpl::start_with_next([=](QSize size, int) { const auto expanding = false; const auto additionalScroll = st::boxRadius; - const auto full = !wrap->scrollBottomSkip(); + const auto full = !_content->scrollBottomSkip(); const auto height = size.height() - (full ? 0 : st::boxRadius); const auto wrapGeometry = QRect{ 0, 0, size.width(), height }; - wrap->updateGeometry(wrapGeometry, expanding, additionalScroll); - }, _content->lifetime()); + _content->updateGeometry(wrapGeometry, expanding, additionalScroll); + }, lifetime()); _connecting = std::make_unique( _content.data(),