mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-11 11:47:09 +02:00
Fix crashes in empty repaint callbacks.
This commit is contained in:
parent
cc4a5f30b6
commit
0537c5f273
3 changed files with 17 additions and 5 deletions
|
@ -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() {
|
||||
|
|
|
@ -104,7 +104,7 @@ void PreviewPainter::setDocument(
|
|||
}
|
||||
if (_player) {
|
||||
_player->setRepaintCallback(updateCallback);
|
||||
} else {
|
||||
} else if (updateCallback) {
|
||||
updateCallback();
|
||||
}
|
||||
}, _lifetime);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue