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"
ProcessorArchitecture="x64"
Publisher="CN=Telegram Messenger LLP, O=Telegram Messenger LLP, L=London, C=GB"
Version="1.0.19.0" />
Version="1.0.20.0" />
<Properties>
<DisplayName>Telegram Desktop</DisplayName>
<PublisherDisplayName>Telegram Messenger LLP</PublisherDisplayName>

View File

@ -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"

View File

@ -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"

View File

@ -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;

View File

@ -321,9 +321,15 @@ void Manager::doClearFromItem(HistoryItem *item) {
return (queued.item == item);
}), _queuedNotifications.cend());
auto showNext = false;
for_const (auto &notification, _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 {

View File

@ -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);

View File

@ -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

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)
- Go to date. Click on the date in a chat to jump to a specific day.