Fix crash in PiP with bad video files.

This commit is contained in:
John Preston 2020-06-05 14:26:42 +04:00
parent 05df4f832b
commit 06629ad171
2 changed files with 8 additions and 2 deletions

View File

@ -1152,7 +1152,7 @@ void Pip::paint(QPainter &p, FrameRequest request) {
} else {
p.drawImage(rect, RotateFrameImage(image, _rotation));
}
if (_instance.player().ready()) {
if (canUseVideoFrame()) {
_instance.markFrameShown();
}
paintRadialLoading(p);
@ -1377,8 +1377,13 @@ void Pip::restartAtSeekPosition(crl::time position) {
updatePlaybackState();
}
bool Pip::canUseVideoFrame() const {
return _instance.player().ready()
&& !_instance.info().video.cover.isNull();
}
QImage Pip::videoFrame(const FrameRequest &request) const {
if (_instance.player().ready()) {
if (canUseVideoFrame()) {
_preparedCoverStorage = QImage();
return _instance.frame(request);
}

View File

@ -169,6 +169,7 @@ private:
void updatePlayPauseResumeState(const Player::TrackState &state);
void restartAtSeekPosition(crl::time position);
[[nodiscard]] bool canUseVideoFrame() const;
[[nodiscard]] QImage videoFrame(const FrameRequest &request) const;
[[nodiscard]] QImage videoFrameForDirectPaint(
const FrameRequest &request) const;