2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Don't hold session pointer in Data::CloudImage.

This commit is contained in:
John Preston
2020-05-28 17:51:18 +04:00
parent 29a498b959
commit 249f7813c1
11 changed files with 81 additions and 53 deletions

View File

@@ -59,7 +59,7 @@ Inner::Inner(
setMouseTracking(true);
setAttribute(Qt::WA_OpaquePaintEvent);
subscribe(Auth().downloaderTaskFinished(), [this] {
subscribe(_controller->session().downloaderTaskFinished(), [this] {
update();
});
subscribe(controller->gifPauseLevelChanged(), [this] {
@@ -1056,13 +1056,15 @@ void Widget::inlineResultsDone(const MTPmessages_BotResults &result) {
auto adding = (it != _inlineCache.cend());
if (result.type() == mtpc_messages_botResults) {
auto &d = result.c_messages_botResults();
Auth().data().processUsers(d.vusers());
_controller->session().data().processUsers(d.vusers());
auto &v = d.vresults().v;
auto queryId = d.vquery_id().v;
if (it == _inlineCache.cend()) {
it = _inlineCache.emplace(_inlineQuery, std::make_unique<internal::CacheEntry>()).first;
it = _inlineCache.emplace(
_inlineQuery,
std::make_unique<internal::CacheEntry>()).first;
}
auto entry = it->second.get();
entry->nextOffset = qs(d.vnext_offset().value_or_empty());
@@ -1077,8 +1079,12 @@ void Widget::inlineResultsDone(const MTPmessages_BotResults &result) {
entry->results.reserve(entry->results.size() + count);
}
auto added = 0;
for_const (const auto &res, v) {
if (auto result = InlineBots::Result::create(queryId, res)) {
for (const auto &res : v) {
auto result = InlineBots::Result::Create(
&_controller->session(),
queryId,
res);
if (result) {
++added;
entry->results.push_back(std::move(result));
}