mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Fix possible crash in Recent Actions.
This commit is contained in:
parent
a333615e53
commit
939f6095ba
2 changed files with 20 additions and 7 deletions
|
@ -273,13 +273,13 @@ InnerWidget::InnerWidget(
|
|||
_scrollDateHideTimer.setCallback([=] { scrollDateHideByTimer(); });
|
||||
session().data().viewRepaintRequest(
|
||||
) | rpl::start_with_next([=](auto view) {
|
||||
if (view->delegate() == this) {
|
||||
if (myView(view)) {
|
||||
repaintItem(view);
|
||||
}
|
||||
}, lifetime());
|
||||
session().data().viewResizeRequest(
|
||||
) | rpl::start_with_next([=](auto view) {
|
||||
if (view->delegate() == this) {
|
||||
if (myView(view)) {
|
||||
resizeItem(view);
|
||||
}
|
||||
}, lifetime());
|
||||
|
@ -291,7 +291,7 @@ InnerWidget::InnerWidget(
|
|||
}, lifetime());
|
||||
session().data().viewLayoutChanged(
|
||||
) | rpl::start_with_next([=](auto view) {
|
||||
if (view->delegate() == this) {
|
||||
if (myView(view)) {
|
||||
if (view->isUnderCursor()) {
|
||||
updateSelected();
|
||||
}
|
||||
|
@ -333,6 +333,10 @@ InnerWidget::InnerWidget(
|
|||
[=] { requestAdmins(); }));
|
||||
}
|
||||
|
||||
bool InnerWidget::myView(not_null<const HistoryView::Element*> view) const {
|
||||
return !_items.empty() && (view->delegate().get() == this);
|
||||
}
|
||||
|
||||
Main::Session &InnerWidget::session() const {
|
||||
return _controller->session();
|
||||
}
|
||||
|
@ -790,11 +794,16 @@ void InnerWidget::saveState(not_null<SectionMemento*> memento) {
|
|||
}
|
||||
|
||||
void InnerWidget::restoreState(not_null<SectionMemento*> memento) {
|
||||
_items = memento->takeItems();
|
||||
for (auto &item : _items) {
|
||||
// OwnedItem::refreshView may call requestItemResize.
|
||||
// So we postpone resizing until all views are created.
|
||||
_items.clear();
|
||||
auto items = memento->takeItems();
|
||||
for (auto &item : items) {
|
||||
item.refreshView(this);
|
||||
_itemsByData.emplace(item->data(), item.get());
|
||||
}
|
||||
_items = std::move(items);
|
||||
|
||||
_eventIds = memento->takeEventIds();
|
||||
_admins = memento->takeAdmins();
|
||||
_adminsCanEdit = memento->takeAdminsCanEdit();
|
||||
|
|
|
@ -229,8 +229,12 @@ private:
|
|||
void paintEmpty(Painter &p, not_null<const Ui::ChatStyle*> st);
|
||||
void clearAfterFilterChange();
|
||||
void clearAndRequestLog();
|
||||
void addEvents(Direction direction, const QVector<MTPChannelAdminLogEvent> &events);
|
||||
Element *viewForItem(const HistoryItem *item);
|
||||
void addEvents(
|
||||
Direction direction,
|
||||
const QVector<MTPChannelAdminLogEvent> &events);
|
||||
[[nodiscard]] Element *viewForItem(const HistoryItem *item);
|
||||
[[nodiscard]] bool myView(
|
||||
not_null<const HistoryView::Element*> view) const;
|
||||
|
||||
void toggleScrollDateShown();
|
||||
void repaintScrollDateCallback();
|
||||
|
|
Loading…
Add table
Reference in a new issue