2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

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

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