Fix possible crash in reply returns.

This commit is contained in:
John Preston 2018-05-10 14:56:36 +03:00
parent 5c5bccae0b
commit e3c6abfc3d
2 changed files with 17 additions and 9 deletions

View file

@ -1558,7 +1558,9 @@ void HistoryWidget::calcNextReplyReturn() {
_replyReturn = App::histItemById(_channel, _replyReturns.back());
}
}
if (!_replyReturn) updateControlsVisibility();
if (!_replyReturn) {
updateControlsVisibility();
}
}
void HistoryWidget::fastShowAtEnd(not_null<History*> history) {
@ -1659,11 +1661,13 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
}
clearDelayedShowAt();
if (_replyReturn) {
while (_replyReturn) {
if (_replyReturn->history() == _history && _replyReturn->id == showAtMsgId) {
calcNextReplyReturn();
} else if (_replyReturn->history() == _migrated && -_replyReturn->id == showAtMsgId) {
calcNextReplyReturn();
} else {
break;
}
}
@ -2431,11 +2435,15 @@ void HistoryWidget::messagesReceived(PeerData *peer, const MTPmessages_Messages
return;
}
}
if (_replyReturn) {
if (_replyReturn->history() == _history && _replyReturn->id == _delayedShowAtMsgId) {
while (_replyReturn) {
if (_replyReturn->history() == _history
&& _replyReturn->id == _delayedShowAtMsgId) {
calcNextReplyReturn();
} else if (_replyReturn->history() == _migrated && -_replyReturn->id == _delayedShowAtMsgId) {
} else if (_replyReturn->history() == _migrated
&& -_replyReturn->id == _delayedShowAtMsgId) {
calcNextReplyReturn();
} else {
break;
}
}
@ -4615,7 +4623,7 @@ void HistoryWidget::itemRemoved(not_null<const HistoryItem*> item) {
cancelReply();
}
}
if (item == _replyReturn) {
while (item == _replyReturn) {
calcNextReplyReturn();
}
if (_pinnedBar && item->id == _pinnedBar->msgId) {

View file

@ -46,9 +46,9 @@ qint32 HTTPConnection::handleError(QNetworkReply *reply) { // returnes "maybe ba
switch (reply->error()) {
case QNetworkReply::ConnectionRefusedError: LOG(("HTTP Error: connection refused - %1").arg(reply->errorString())); break;
case QNetworkReply::RemoteHostClosedError: LOG(("HTTP Error: remote host closed - %1").arg(reply->errorString())); break;
case QNetworkReply::HostNotFoundError: LOG(("HTTP Error: host not found - %2").arg(reply->error()).arg(reply->errorString())); break;
case QNetworkReply::TimeoutError: LOG(("HTTP Error: timeout - %2").arg(reply->error()).arg(reply->errorString())); break;
case QNetworkReply::OperationCanceledError: LOG(("HTTP Error: cancelled - %2").arg(reply->error()).arg(reply->errorString())); break;
case QNetworkReply::HostNotFoundError: LOG(("HTTP Error: host not found - %1").arg(reply->errorString())); break;
case QNetworkReply::TimeoutError: LOG(("HTTP Error: timeout - %1").arg(reply->errorString())); break;
case QNetworkReply::OperationCanceledError: LOG(("HTTP Error: cancelled - %1").arg(reply->errorString())); break;
case QNetworkReply::SslHandshakeFailedError:
case QNetworkReply::TemporaryNetworkFailureError:
case QNetworkReply::NetworkSessionFailedError: