From aef88559e896c921e3e1c2c03568b67e6be2a01f Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 8 Dec 2017 17:54:08 +0400 Subject: [PATCH] Fix possible crash in HistoryWidget. Stack in crash reports leads to something like that: - HistoryWidget::showHistory - _scroll->setOwnedWidget - Ui::ScrollArea::onScrolled - sendSynteticMouseEvent - Info::Media::ListWidget::enterEventHook - Info::Media::ListWidget::mouseAction?Update - Overview::Layout::ItemBase::clickHandlerActiveChanged - AuthSessionData::requestItemRepaint - HistoryWidget::repaintHistoryItem Workaround: - Don't accept repaint item requests while _list is not set yet. --- Telegram/SourceFiles/history/history_widget.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 9946f85c7..944e8513a 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -4657,6 +4657,15 @@ void HistoryWidget::grabFinish() { void HistoryWidget::repaintHistoryItem( not_null item) { + // It is possible that repaintHistoryItem() will be called from + // _scroll->setOwnedWidget() because it calls onScroll() that + // sendSynteticMouseEvent() and it could lead to some Info layout + // calling Auth().data().requestItemRepaint(), while we still are + // in progrss of showing the history. Just ignore them for now :/ + if (!_list) { + return; + } + auto itemHistory = item->history(); if (itemHistory == _history || itemHistory == _migrated) { auto ms = getms();