2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

Fix crash in session destruction.

Also use rpl::event_stream for downloaderTaskFinished.
This commit is contained in:
John Preston
2020-07-01 12:03:34 +04:00
parent 0981335ca7
commit eb1845e33b
38 changed files with 129 additions and 78 deletions

View File

@@ -1364,7 +1364,10 @@ void RevokePublicLinkBox::prepare() {
addButton(tr::lng_cancel(), [=] { closeBox(); });
subscribe(_session->downloaderTaskFinished(), [=] { update(); });
_session->downloaderTaskFinished(
) | rpl::start_with_next([=] {
update();
}, lifetime());
_inner->resizeToWidth(st::boxWideWidth);
setDimensions(st::boxWideWidth, _innerTop + _inner->height());

View File

@@ -203,7 +203,10 @@ BackgroundBox::Inner::Inner(
}
requestPapers();
subscribe(_session->downloaderTaskFinished(), [=] { update(); });
_session->downloaderTaskFinished(
) | rpl::start_with_next([=] {
update();
}, lifetime());
using Update = Window::Theme::BackgroundUpdate;
subscribe(Window::Theme::Background(), [=](const Update &update) {
if (update.paletteChanged()) {

View File

@@ -419,9 +419,10 @@ BackgroundPreviewBox::BackgroundPreviewBox(
if (_media) {
_media->thumbnailWanted(_paper.fileOrigin());
}
subscribe(_controller->session().downloaderTaskFinished(), [=] {
_controller->session().downloaderTaskFinished(
) | rpl::start_with_next([=] {
update();
});
}, lifetime());
}
not_null<HistoryView::ElementDelegate*> BackgroundPreviewBox::delegate() {

View File

@@ -891,9 +891,10 @@ ConfirmInviteBox::ConfirmInviteBox(
_photo = photo->createMediaView();
_photo->wanted(Data::PhotoSize::Small, Data::FileOrigin());
if (!_photo->image(Data::PhotoSize::Small)) {
subscribe(_session->downloaderTaskFinished(), [=] {
_session->downloaderTaskFinished(
) | rpl::start_with_next([=] {
update();
});
}, lifetime());
}
} else {
_photoEmpty = std::make_unique<Ui::EmptyUserpic>(

View File

@@ -291,7 +291,8 @@ EditCaptionBox::EditCaptionBox(
Assert(_thumbnailImageLoaded || _refreshThumbnail);
if (!_thumbnailImageLoaded) {
subscribe(_controller->session().downloaderTaskFinished(), [=] {
_controller->session().downloaderTaskFinished(
) | rpl::start_with_next([=] {
if (_thumbnailImageLoaded
|| (_photoMedia && !_photoMedia->image(PhotoSize::Large))
|| (_documentMedia && !_documentMedia->thumbnail())) {
@@ -299,7 +300,7 @@ EditCaptionBox::EditCaptionBox(
}
_refreshThumbnail();
update();
});
}, lifetime());
}
_field.create(
this,

View File

@@ -662,9 +662,10 @@ PeerListContent::PeerListContent(
, _st(st)
, _controller(controller)
, _rowHeight(_st.item.height) {
subscribe(_controller->session().downloaderTaskFinished(), [=] {
_controller->session().downloaderTaskFinished(
) | rpl::start_with_next([=] {
update();
});
}, lifetime());
using UpdateFlag = Data::PeerUpdate::Flag;
_controller->session().changes().peerUpdates(

View File

@@ -570,9 +570,10 @@ ShareBox::Inner::Inner(
update.oldFirstLetters);
}, lifetime());
subscribe(_navigation->session().downloaderTaskFinished(), [=] {
_navigation->session().downloaderTaskFinished(
) | rpl::start_with_next([=] {
update();
});
}, lifetime());
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) {
if (update.paletteChanged()) {

View File

@@ -254,7 +254,10 @@ StickerSetBox::Inner::Inner(
_controller->session().api().updateStickers();
subscribe(_controller->session().downloaderTaskFinished(), [this] { update(); });
_controller->session().downloaderTaskFinished(
) | rpl::start_with_next([=] {
update();
}, lifetime());
setMouseTracking(true);
}

View File

@@ -1002,10 +1002,12 @@ Main::Session &StickersBox::Inner::session() const {
}
void StickersBox::Inner::setup() {
subscribe(session().downloaderTaskFinished(), [this] {
session().downloaderTaskFinished(
) | rpl::start_with_next([=] {
update();
readVisibleSets();
});
}, lifetime());
setMouseTracking(true);
}