Fix crash in unread bar destruction.

This commit is contained in:
John Preston 2022-12-05 09:47:54 +04:00
parent fe9cf7ddad
commit fbf3168317
2 changed files with 14 additions and 5 deletions

View File

@ -1014,10 +1014,10 @@ void Element::destroyUnreadBar() {
return;
}
RemoveComponents(UnreadBar::Bit());
history()->owner().requestViewResize(this);
if (data()->mainView() == this) {
recountAttachToPreviousInBlocks();
}
history()->owner().requestViewResize(this);
}
int Element::displayedDateHeight() const {

View File

@ -494,6 +494,7 @@ void ListWidget::refreshRows(const Data::MessagesSlice &old) {
) - 1;
auto destroyingBarElement = _bar.element;
auto clearingOverElement = _overElement;
_resizePending = true;
_items.clear();
_items.reserve(_slice.ids.size());
@ -508,18 +509,26 @@ void ListWidget::refreshRows(const Data::MessagesSlice &old) {
if (destroyingBarElement == view) {
destroyingBarElement = nullptr;
}
if (clearingOverElement == view) {
clearingOverElement = nullptr;
}
}
}
if (destroyingBarElement) {
destroyingBarElement->destroyUnreadBar();
_bar = {};
}
for (auto e = end(_items), i = e - addedToEndCount; i != e; ++i) {
_itemRevealPending.emplace(*i);
}
updateAroundPositionFromNearest(nearestIndex);
updateItemsGeometry();
if (clearingOverElement) {
_overElement = nullptr;
}
if (destroyingBarElement) {
destroyingBarElement->destroyUnreadBar();
_bar = {};
}
checkUnreadBarCreation();
restoreScrollState();
if (!_itemsRevealHeight) {