From 5aab168b3ecc16f71217de721915146c3edb0d99 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 8 Mar 2017 23:51:40 +0300 Subject: [PATCH] Alpha 1.0.20: fix crash in default notifications. Before showNextFromQueue() was called from a range-for loop over the _notifications and it invalidated the _notifications iterators. --- Telegram/Resources/uwp/AppX/AppxManifest.xml | 2 +- Telegram/Resources/winrc/Telegram.rc | 8 ++++---- Telegram/Resources/winrc/Updater.rc | 8 ++++---- Telegram/SourceFiles/core/version.h | 4 ++-- .../window/notifications_manager_default.cpp | 18 +++++++++++++----- .../window/notifications_manager_default.h | 2 +- Telegram/build/version | 6 +++--- changelog.txt | 4 ++++ 8 files changed, 32 insertions(+), 20 deletions(-) diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index 184b66b97..9bc50a2e4 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -9,7 +9,7 @@ + Version="1.0.20.0" /> Telegram Desktop Telegram Messenger LLP diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 5a4715ad4..175b5a983 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,19,0 - PRODUCTVERSION 1,0,19,0 + FILEVERSION 1,0,20,0 + PRODUCTVERSION 1,0,20,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -52,10 +52,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram Messenger LLP" VALUE "FileDescription", "Telegram Desktop" - VALUE "FileVersion", "1.0.19.0" + VALUE "FileVersion", "1.0.20.0" VALUE "LegalCopyright", "Copyright (C) 2014-2017" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "1.0.19.0" + VALUE "ProductVersion", "1.0.20.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index 3d2358908..04b937c36 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,19,0 - PRODUCTVERSION 1,0,19,0 + FILEVERSION 1,0,20,0 + PRODUCTVERSION 1,0,20,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -43,10 +43,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram Messenger LLP" VALUE "FileDescription", "Telegram Desktop Updater" - VALUE "FileVersion", "1.0.19.0" + VALUE "FileVersion", "1.0.20.0" VALUE "LegalCopyright", "Copyright (C) 2014-2017" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "1.0.19.0" + VALUE "ProductVersion", "1.0.20.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index ec2df5c2a..c3d344876 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -24,7 +24,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #define BETA_VERSION_MACRO (0ULL) -constexpr int AppVersion = 1000019; -constexpr str_const AppVersionStr = "1.0.19"; +constexpr int AppVersion = 1000020; +constexpr str_const AppVersionStr = "1.0.20"; constexpr bool AppAlphaVersion = true; constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO; diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index 2bfaefc19..0f45ba58b 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -321,9 +321,15 @@ void Manager::doClearFromItem(HistoryItem *item) { return (queued.item == item); }), _queuedNotifications.cend()); + auto showNext = false; for_const (auto ¬ification, _notifications) { - // Calls unlinkFromShown() -> showNextFromQueue() - notification->itemRemoved(item); + if (notification->unlinkItem(item)) { + showNext = true; + } + } + if (showNext) { + // This call invalidates _notifications iterators. + showNextFromQueue(); } } @@ -690,11 +696,13 @@ void Notification::updatePeerPhoto() { update(); } -void Notification::itemRemoved(HistoryItem *deleted) { - if (_item && _item == deleted) { +bool Notification::unlinkItem(HistoryItem *deleted) { + auto unlink = (_item && _item == deleted); + if (unlink) { _item = nullptr; - unlinkHistoryInManager(); + unlinkHistory(); } + return unlink; } bool Notification::canReply() const { diff --git a/Telegram/SourceFiles/window/notifications_manager_default.h b/Telegram/SourceFiles/window/notifications_manager_default.h index 7417c8114..e8666b7a3 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.h +++ b/Telegram/SourceFiles/window/notifications_manager_default.h @@ -198,7 +198,7 @@ public: } // Called only by Manager. - void itemRemoved(HistoryItem *del); + bool unlinkItem(HistoryItem *del); bool unlinkHistory(History *history = nullptr); bool checkLastInput(bool hasReplyingNotifications); diff --git a/Telegram/build/version b/Telegram/build/version index 0da112c1d..e8eee0bcd 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,6 +1,6 @@ -AppVersion 1000019 +AppVersion 1000020 AppVersionStrMajor 1.0 -AppVersionStrSmall 1.0.19 -AppVersionStr 1.0.19 +AppVersionStrSmall 1.0.20 +AppVersionStr 1.0.20 AlphaChannel 1 BetaVersion 0 diff --git a/changelog.txt b/changelog.txt index 4025ba259..4f38c9aa5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +1.0.20 alpha (08.03.17) + +- Bug fixes and other minor improvements. + 1.0.19 alpha (08.03.17) - Go to date. Click on the date in a chat to jump to a specific day.