Fix crash in audio player hiding.

This commit is contained in:
John Preston 2017-12-27 10:18:09 +03:00
parent b34099f49e
commit bd8dee0972
2 changed files with 7 additions and 2 deletions

View File

@ -1744,7 +1744,7 @@ void MainWidget::createPlayer() {
_player->shownValue()
) | rpl::start_with_next(
[this] { playerHeightUpdated(); },
lifetime());
_player->lifetime());
_player->entity()->setCloseCallback([this] { closeBothPlayers(); });
_playerVolume.create(this);
_player->entity()->volumeWidgetCreated(_playerVolume);
@ -1768,6 +1768,10 @@ void MainWidget::createPlayer() {
}
void MainWidget::playerHeightUpdated() {
if (!_player) {
// Player could be already "destroyDelayed", but still handle events.
return;
}
auto playerHeight = _player->contentHeight();
if (playerHeight != _playerHeight) {
_contentScrollAddToY += playerHeight - _playerHeight;

View File

@ -120,8 +120,9 @@ void SlideWrap<RpWidget>::animationStep() {
}
auto shouldBeHidden = !_toggled && !_animation.animating();
if (shouldBeHidden != isHidden()) {
const auto guard = make_weak(this);
setVisible(!shouldBeHidden);
if (shouldBeHidden) {
if (shouldBeHidden && guard) {
SendPendingMoveResizeEvents(this);
}
}