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

View File

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