Fix crash in cloud lang manager destructor.

This commit is contained in:
John Preston 2023-02-12 15:01:39 +04:00
parent d0c2bec925
commit 1da635a5dd
3 changed files with 23 additions and 24 deletions

View file

@ -148,18 +148,19 @@ auto ProcessAlternativeName(Info &&info) {
Manager::Manager(not_null<Main::Domain*> domain)
: _path(cWorkingDir() + "tdata/countries") {
read();
const auto mtpLifetime = _lifetime.make_state<rpl::lifetime>();
domain->activeValue(
) | rpl::map([=](Main::Account *account) {
if (!account) {
_api.reset();
}
return account
? account->mtpMainSessionValue()
: rpl::never<not_null<MTP::Instance*>>();
}) | rpl::flatten_latest(
) | rpl::start_with_next([=](not_null<MTP::Instance*> instance) {
_api.emplace(instance);
request();
) | rpl::filter([=](Main::Account *account) {
return (account != nullptr);
}) | rpl::start_with_next_done([=](Main::Account *account) {
*mtpLifetime = account->mtpMainSessionValue(
) | rpl::start_with_next([=](not_null<MTP::Instance*> instance) {
_api.emplace(instance);
request();
});
}, [=] {
_api.reset();
}, _lifetime);
}

View file

@ -158,18 +158,18 @@ Language ParseLanguage(const MTPLangPackLanguage &data) {
CloudManager::CloudManager(Instance &langpack)
: _langpack(langpack) {
const auto mtpLifetime = _lifetime.make_state<rpl::lifetime>();
Core::App().domain().activeValue(
) | rpl::map([=](Main::Account *account) {
if (!account) {
_api.reset();
}
return account
? account->mtpMainSessionValue()
: rpl::never<not_null<MTP::Instance*>>();
}) | rpl::flatten_latest(
) | rpl::start_with_next([=](not_null<MTP::Instance*> instance) {
_api.emplace(instance);
resendRequests();
) | rpl::filter([=](Main::Account *account) {
return (account != nullptr);
}) | rpl::start_with_next_done([=](Main::Account *account) {
*mtpLifetime = account->mtpMainSessionValue(
) | rpl::start_with_next([=](not_null<MTP::Instance*> instance) {
_api.emplace(instance);
resendRequests();
});
}, [=] {
_api.reset();
}, _lifetime);
}

View file

@ -202,8 +202,6 @@ Account &Domain::active() const {
return *_active.current();
}
rpl::producer<not_null<Account*>> Domain::activeChanges() const {
return _active.changes() | rpl::map([](Account *value) {
return not_null{ value };