Fix crash in stickers box.

This commit is contained in:
John Preston 2020-06-04 12:16:56 +04:00
parent bfafdd5b38
commit bf06d4d545
1 changed files with 17 additions and 9 deletions

View File

@ -1921,20 +1921,28 @@ void StickersBox::Inner::readVisibleSets() {
int rowFrom = floorclamp(itemsVisibleTop, _rowHeight, 0, _rows.size()); int rowFrom = floorclamp(itemsVisibleTop, _rowHeight, 0, _rows.size());
int rowTo = ceilclamp(itemsVisibleBottom, _rowHeight, 0, _rows.size()); int rowTo = ceilclamp(itemsVisibleBottom, _rowHeight, 0, _rows.size());
for (int i = rowFrom; i < rowTo; ++i) { for (int i = rowFrom; i < rowTo; ++i) {
if (!_rows[i]->unread) { const auto row = _rows[i].get();
if (!row->unread) {
continue; continue;
} }
if (i * _rowHeight < itemsVisibleTop || (i + 1) * _rowHeight > itemsVisibleBottom) { if ((i * _rowHeight < itemsVisibleTop)
|| ((i + 1) * _rowHeight > itemsVisibleBottom)) {
continue; continue;
} }
const auto thumbnailLoading = _rows[i]->set->hasThumbnail() const auto thumbnailLoading = row->set->hasThumbnail()
? _rows[i]->set->thumbnailLoading() ? row->set->thumbnailLoading()
: _rows[i]->sticker : row->sticker
? ((_rows[i]->stickerMedia && _rows[i]->stickerMedia->loaded()) ? row->sticker->thumbnailLoading()
|| _rows[i]->sticker->thumbnailLoading())
: false; : false;
if (!thumbnailLoading || _rows[i]->stickerMedia->loaded()) { const auto thumbnailLoaded = row->set->hasThumbnail()
_session->api().readFeaturedSetDelayed(_rows[i]->set->id); ? (row->thumbnailMedia
&& (row->thumbnailMedia->image()
|| !row->thumbnailMedia->content().isEmpty()))
: row->sticker
? (row->stickerMedia && row->stickerMedia->loaded())
: true;
if (!thumbnailLoading || thumbnailLoaded) {
_session->api().readFeaturedSetDelayed(row->set->id);
} }
} }
} }