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.
This commit is contained in:
John Preston 2017-03-08 23:51:40 +03:00
parent ce8d68fc8c
commit 5aab168b3e
8 changed files with 32 additions and 20 deletions

View file

@ -9,7 +9,7 @@
<Identity Name="TelegramDesktop" <Identity Name="TelegramDesktop"
ProcessorArchitecture="x64" ProcessorArchitecture="x64"
Publisher="CN=Telegram Messenger LLP, O=Telegram Messenger LLP, L=London, C=GB" Publisher="CN=Telegram Messenger LLP, O=Telegram Messenger LLP, L=London, C=GB"
Version="1.0.19.0" /> Version="1.0.20.0" />
<Properties> <Properties>
<DisplayName>Telegram Desktop</DisplayName> <DisplayName>Telegram Desktop</DisplayName>
<PublisherDisplayName>Telegram Messenger LLP</PublisherDisplayName> <PublisherDisplayName>Telegram Messenger LLP</PublisherDisplayName>

View file

@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,19,0 FILEVERSION 1,0,20,0
PRODUCTVERSION 1,0,19,0 PRODUCTVERSION 1,0,20,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -52,10 +52,10 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Telegram Messenger LLP" VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileDescription", "Telegram Desktop" VALUE "FileDescription", "Telegram Desktop"
VALUE "FileVersion", "1.0.19.0" VALUE "FileVersion", "1.0.20.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2017" VALUE "LegalCopyright", "Copyright (C) 2014-2017"
VALUE "ProductName", "Telegram Desktop" VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "1.0.19.0" VALUE "ProductVersion", "1.0.20.0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,19,0 FILEVERSION 1,0,20,0
PRODUCTVERSION 1,0,19,0 PRODUCTVERSION 1,0,20,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -43,10 +43,10 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Telegram Messenger LLP" VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileDescription", "Telegram Desktop Updater" VALUE "FileDescription", "Telegram Desktop Updater"
VALUE "FileVersion", "1.0.19.0" VALUE "FileVersion", "1.0.20.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2017" VALUE "LegalCopyright", "Copyright (C) 2014-2017"
VALUE "ProductName", "Telegram Desktop" VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "1.0.19.0" VALUE "ProductVersion", "1.0.20.0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -24,7 +24,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#define BETA_VERSION_MACRO (0ULL) #define BETA_VERSION_MACRO (0ULL)
constexpr int AppVersion = 1000019; constexpr int AppVersion = 1000020;
constexpr str_const AppVersionStr = "1.0.19"; constexpr str_const AppVersionStr = "1.0.20";
constexpr bool AppAlphaVersion = true; constexpr bool AppAlphaVersion = true;
constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO; constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO;

View file

@ -321,9 +321,15 @@ void Manager::doClearFromItem(HistoryItem *item) {
return (queued.item == item); return (queued.item == item);
}), _queuedNotifications.cend()); }), _queuedNotifications.cend());
auto showNext = false;
for_const (auto &notification, _notifications) { for_const (auto &notification, _notifications) {
// Calls unlinkFromShown() -> showNextFromQueue() if (notification->unlinkItem(item)) {
notification->itemRemoved(item); showNext = true;
}
}
if (showNext) {
// This call invalidates _notifications iterators.
showNextFromQueue();
} }
} }
@ -690,11 +696,13 @@ void Notification::updatePeerPhoto() {
update(); update();
} }
void Notification::itemRemoved(HistoryItem *deleted) { bool Notification::unlinkItem(HistoryItem *deleted) {
if (_item && _item == deleted) { auto unlink = (_item && _item == deleted);
if (unlink) {
_item = nullptr; _item = nullptr;
unlinkHistoryInManager(); unlinkHistory();
} }
return unlink;
} }
bool Notification::canReply() const { bool Notification::canReply() const {

View file

@ -198,7 +198,7 @@ public:
} }
// Called only by Manager. // Called only by Manager.
void itemRemoved(HistoryItem *del); bool unlinkItem(HistoryItem *del);
bool unlinkHistory(History *history = nullptr); bool unlinkHistory(History *history = nullptr);
bool checkLastInput(bool hasReplyingNotifications); bool checkLastInput(bool hasReplyingNotifications);

View file

@ -1,6 +1,6 @@
AppVersion 1000019 AppVersion 1000020
AppVersionStrMajor 1.0 AppVersionStrMajor 1.0
AppVersionStrSmall 1.0.19 AppVersionStrSmall 1.0.20
AppVersionStr 1.0.19 AppVersionStr 1.0.20
AlphaChannel 1 AlphaChannel 1
BetaVersion 0 BetaVersion 0

View file

@ -1,3 +1,7 @@
1.0.20 alpha (08.03.17)
- Bug fixes and other minor improvements.
1.0.19 alpha (08.03.17) 1.0.19 alpha (08.03.17)
- Go to date. Click on the date in a chat to jump to a specific day. - Go to date. Click on the date in a chat to jump to a specific day.