From 41f2cc6d81c8d874dd55cd4ee491bec15d7dc324 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 19:33:22 +0400 Subject: [PATCH] Fix crash in notifications clearing. --- Telegram/SourceFiles/core/application.cpp | 1 + Telegram/SourceFiles/core/application.h | 9 +++++---- .../SourceFiles/window/notifications_manager_default.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index cfeaf930f..19bd5000c 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -153,6 +153,7 @@ Application::~Application() { _window = nullptr; _mediaView = nullptr; + _notifications->clearAllFast(); _domain->finish(); Local::finish(); diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index da79b9b7f..4215a9828 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -331,6 +331,11 @@ private: base::Timer _clearEmojiImageLoaderTimer; const std::unique_ptr _audio; mutable std::unique_ptr _fallbackProductionConfig; + + // Notifications should be destroyed before _audio, after _domain. + // Mutable because is created in run() after OpenSSL is inited. + std::unique_ptr _notifications; + const std::unique_ptr _domain; const std::unique_ptr _exportManager; const std::unique_ptr _calls; @@ -347,10 +352,6 @@ private: Media::Player::FloatDelegate *_defaultFloatPlayerDelegate = nullptr; Media::Player::FloatDelegate *_replacementFloatPlayerDelegate = nullptr; - // Notifications should be destroyed before _audio. - // Mutable because is created in run() after OpenSSL is inited. - std::unique_ptr _notifications; - const QImage _logo; const QImage _logoNoMargin; diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index d9eba08a3..2932e89ae 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -192,7 +192,7 @@ void Manager::showNextFromQueue() { return; } int count = Core::App().settings().notificationsCount(); - for_const (auto ¬ification, _notifications) { + for (const auto ¬ification : _notifications) { if (notification->isUnlinked()) continue; --count; }