Fix crash in AdminLog view with deleted delegates.

This commit is contained in:
John Preston 2018-03-22 02:26:19 +04:00
parent 9aa2831fef
commit d6e1862c08
3 changed files with 13 additions and 3 deletions

View file

@ -531,6 +531,9 @@ void InnerWidget::saveState(not_null<SectionMemento*> memento) {
void InnerWidget::restoreState(not_null<SectionMemento*> memento) {
_items = memento->takeItems();
for (auto &item : _items) {
item.refreshView(this);
}
_itemsByIds = memento->takeItemsByIds();
if (auto manager = memento->takeIdManager()) {
_idManager = std::move(manager);

View file

@ -195,9 +195,9 @@ auto GenerateBannedChangeText(const TextWithEntities &user, const MTPChannelBann
lt_date,
langDateTime(ParseDateTime(newUntil)));
auto result = lng_admin_log_restricted__generic(
lt_user,
user,
lt_until,
lt_user,
user,
lt_until,
TextWithEntities { untilText });
static auto phraseMap = std::map<Flags, LangKey> {
@ -317,6 +317,11 @@ OwnedItem::~OwnedItem() {
}
}
void OwnedItem::refreshView(
not_null<HistoryView::ElementDelegate*> delegate) {
_view = _data->createView(delegate);
}
void GenerateItems(
not_null<HistoryView::ElementDelegate*> delegate,
not_null<History*> history,

View file

@ -46,6 +46,8 @@ public:
return get();
}
void refreshView(not_null<HistoryView::ElementDelegate*> delegate);
private:
HistoryItem *_data = nullptr;
std::unique_ptr<HistoryView::Element> _view;