Fix crash in local messages tracking.

This commit is contained in:
John Preston 2019-08-31 14:25:24 +03:00
parent 3b4563772e
commit 791ae64a90
2 changed files with 7 additions and 2 deletions

View file

@ -1270,6 +1270,9 @@ void History::newItemAdded(not_null<HistoryItem*> item) {
}
void History::registerLocalMessage(not_null<HistoryItem*> item) {
Expects(item->isHistoryEntry());
Expects(IsClientMsgId(item->id));
_localMessages.emplace(item);
if (peer->isChannel()) {
Notify::peerUpdatedDelayed(
@ -1279,7 +1282,9 @@ void History::registerLocalMessage(not_null<HistoryItem*> item) {
}
void History::unregisterLocalMessage(not_null<HistoryItem*> item) {
_localMessages.remove(item);
const auto removed = _localMessages.remove(item);
Assert(removed);
if (peer->isChannel()) {
Notify::peerUpdatedDelayed(
peer,

View file

@ -178,7 +178,7 @@ HistoryItem::HistoryItem(
, _flags(flags)
, _clientFlags(clientFlags)
, _date(date) {
if (IsClientMsgId(id)) {
if (isHistoryEntry() && IsClientMsgId(id)) {
_history->registerLocalMessage(this);
}
}