Fix a crash in round videos with a message text.

This commit is contained in:
John Preston 2017-05-26 15:20:11 +03:00
parent 6052a0de0e
commit 10e34aa996
3 changed files with 16 additions and 10 deletions

View File

@ -1941,9 +1941,10 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeM
} }
auto usex = 0, usew = width; auto usex = 0, usew = width;
auto via = (!isRound || isChildMedia) ? nullptr : _parent->Get<HistoryMessageVia>(); auto separateRoundVideo = isSeparateRoundVideo();
auto reply = (!isRound || isChildMedia) ? nullptr : _parent->Get<HistoryMessageReply>(); auto via = separateRoundVideo ? _parent->Get<HistoryMessageVia>() : nullptr;
auto forwarded = (!isRound || isChildMedia) ? nullptr : _parent->Get<HistoryMessageForwarded>(); auto reply = separateRoundVideo ? _parent->Get<HistoryMessageReply>() : nullptr;
auto forwarded = separateRoundVideo ? _parent->Get<HistoryMessageForwarded>() : nullptr;
if (via || reply || forwarded) { if (via || reply || forwarded) {
usew = _maxw - additionalWidth(via, reply, forwarded); usew = _maxw - additionalWidth(via, reply, forwarded);
if (isPost) { if (isPost) {
@ -2180,11 +2181,11 @@ HistoryTextState HistoryGif::getState(int x, int y, HistoryStateRequest request)
} }
auto out = _parent->out(), isPost = _parent->isPost(); auto out = _parent->out(), isPost = _parent->isPost();
auto isChildMedia = (_parent->getMedia() != this); auto isChildMedia = (_parent->getMedia() != this);
auto isRound = _data->isRoundVideo();
auto usew = width, usex = 0; auto usew = width, usex = 0;
auto via = (!isRound || isChildMedia) ? nullptr : _parent->Get<HistoryMessageVia>(); auto separateRoundVideo = isSeparateRoundVideo();
auto reply = (!isRound || isChildMedia) ? nullptr : _parent->Get<HistoryMessageReply>(); auto via = separateRoundVideo ? _parent->Get<HistoryMessageVia>() : nullptr;
auto forwarded = (!isRound || isChildMedia) ? nullptr : _parent->Get<HistoryMessageForwarded>(); auto reply = separateRoundVideo ? _parent->Get<HistoryMessageReply>() : nullptr;
auto forwarded = separateRoundVideo ? _parent->Get<HistoryMessageForwarded>() : nullptr;
if (via || reply || forwarded) { if (via || reply || forwarded) {
usew = _maxw - additionalWidth(via, reply, forwarded); usew = _maxw - additionalWidth(via, reply, forwarded);
if (isPost) { if (isPost) {
@ -2306,6 +2307,10 @@ QString HistoryGif::mediaTypeString() const {
return _data->isRoundVideo() ? lang(lng_in_dlg_video_message) : qsl("GIF"); return _data->isRoundVideo() ? lang(lng_in_dlg_video_message) : qsl("GIF");
} }
bool HistoryGif::isSeparateRoundVideo() const {
return _data->isRoundVideo() && (_parent->getMedia() == this) && !_parent->hasBubble();
}
void HistoryGif::setStatusSize(int32 newSize) const { void HistoryGif::setStatusSize(int32 newSize) const {
if (_data->isRoundVideo()) { if (_data->isRoundVideo()) {
_statusSize = newSize; _statusSize = newSize;

View File

@ -583,9 +583,7 @@ private:
return additionalWidth(_parent->Get<HistoryMessageVia>(), _parent->Get<HistoryMessageReply>(), _parent->Get<HistoryMessageForwarded>()); return additionalWidth(_parent->Get<HistoryMessageVia>(), _parent->Get<HistoryMessageReply>(), _parent->Get<HistoryMessageForwarded>());
} }
QString mediaTypeString() const; QString mediaTypeString() const;
bool isSeparateRoundVideo() const { bool isSeparateRoundVideo() const;
return _data->isRoundVideo() && (_parent->getMedia() == this);
}
gsl::not_null<DocumentData*> _data; gsl::not_null<DocumentData*> _data;
ClickHandlerPtr _openInMediaviewLink; ClickHandlerPtr _openInMediaviewLink;

View File

@ -223,6 +223,9 @@ void Reader::start(int32 framew, int32 frameh, int32 outerw, int32 outerh, Image
} }
QPixmap Reader::current(int32 framew, int32 frameh, int32 outerw, int32 outerh, ImageRoundRadius radius, ImageRoundCorners corners, TimeMs ms) { QPixmap Reader::current(int32 framew, int32 frameh, int32 outerw, int32 outerh, ImageRoundRadius radius, ImageRoundCorners corners, TimeMs ms) {
Expects(outerw > 0);
Expects(outerh > 0);
auto frame = frameToShow(); auto frame = frameToShow();
t_assert(frame != nullptr); t_assert(frame != nullptr);