Fix crashes in empty repaint callbacks.

This commit is contained in:
John Preston 2025-03-08 07:05:45 +04:00
parent cc4a5f30b6
commit 0537c5f273
3 changed files with 17 additions and 5 deletions

View file

@ -21,6 +21,10 @@ LottiePlayer::LottiePlayer(std::unique_ptr<Lottie::SinglePlayer> lottie)
}
void LottiePlayer::setRepaintCallback(Fn<void()> callback) {
if (!callback) {
_repaintLifetime.destroy();
return;
}
_repaintLifetime = _lottie->updates(
) | rpl::start_with_next([=](Lottie::Update update) {
v::match(update.data, [&](const Lottie::Information &) {
@ -82,7 +86,9 @@ void WebmPlayer::clipCallback(ClipNotification notification) {
case ClipNotification::Repaint: break;
}
_repaintCallback();
if (const auto onstack = _repaintCallback) {
onstack();
}
}
void WebmPlayer::setRepaintCallback(Fn<void()> callback) {
@ -133,7 +139,9 @@ StaticStickerPlayer::StaticStickerPlayer(
}
void StaticStickerPlayer::setRepaintCallback(Fn<void()> callback) {
callback();
if (callback) {
callback();
}
}
bool StaticStickerPlayer::ready() {

View file

@ -104,7 +104,7 @@ void PreviewPainter::setDocument(
}
if (_player) {
_player->setRepaintCallback(updateCallback);
} else {
} else if (updateCallback) {
updateCallback();
}
}, _lifetime);

View file

@ -194,11 +194,15 @@ void SlideAnimation::start() {
fromLeft ? 0. : 1.,
st::slideDuration,
transition());
_repaintCallback();
if (const auto onstack = _repaintCallback) {
onstack();
}
}
void SlideAnimation::animationCallback() {
_repaintCallback();
if (const auto onstack = _repaintCallback) {
onstack();
}
if (!_animation.animating()) {
if (const auto onstack = _finishedCallback) {
onstack();