From 5aff4cca0e42a154d3086dfbd7e87cc161f62d56 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 1 Sep 2021 19:21:39 +0300 Subject: [PATCH] Fix rare crash in message history resizing. --- Telegram/SourceFiles/history/history_widget.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 7181fa6fb..6810fcbc8 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -5018,6 +5018,8 @@ void HistoryWidget::startItemRevealAnimations() { } void HistoryWidget::updateListSize() { + Expects(_list != nullptr); + _list->recountHistoryGeometry(); auto washidden = _scroll->isHidden(); if (washidden) { @@ -5033,6 +5035,16 @@ void HistoryWidget::updateListSize() { } bool HistoryWidget::hasPendingResizedItems() const { + if (!_list) { + // Based on the crash reports there is a codepath (at least on macOS) + // that leads from _list = _scroll->setOwnedWidget(...) right into + // the HistoryWidget::paintEvent (by sending fake mouse move events + // inside scroll area -> hiding tooltip window -> exposing the main + // window -> syncing it backing store synchronously). + // + // So really we could get here with !_list && (_history != nullptr). + return false; + } return (_history && _history->hasPendingResizedItems()) || (_migrated && _migrated->hasPendingResizedItems()); }