Fix crash in closing export panel.

This commit is contained in:
John Preston 2019-06-24 10:59:21 +02:00
parent e5cfa3fdc9
commit 9c85d58235
3 changed files with 12 additions and 7 deletions

View File

@ -306,7 +306,9 @@ void MainWindow::ensureLayerCreated() {
bodyWidget()); bodyWidget());
_layer->hideFinishEvents( _layer->hideFinishEvents(
) | rpl::start_with_next([=] { ) | rpl::filter([=] {
return _layer != nullptr; // Last hide finish is sent from destructor.
}) | rpl::start_with_next([=] {
destroyLayer(); destroyLayer();
}, _layer->lifetime()); }, _layer->lifetime());
@ -319,12 +321,14 @@ void MainWindow::destroyLayer() {
if (!_layer) { if (!_layer) {
return; return;
} }
auto layer = base::take(_layer); auto layer = base::take(_layer);
const auto resetFocus = Ui::InFocusChain(layer); const auto resetFocus = Ui::InFocusChain(layer);
if (resetFocus) { if (resetFocus) {
setFocus(); setFocus();
} }
layer = nullptr; layer = nullptr;
if (const auto controller = sessionController()) { if (const auto controller = sessionController()) {
controller->disableGifPauseReason(Window::GifPauseReason::Layer); controller->disableGifPauseReason(Window::GifPauseReason::Layer);
} }
@ -337,11 +341,10 @@ void MainWindow::destroyLayer() {
} }
void MainWindow::ui_hideSettingsAndLayer(anim::type animated) { void MainWindow::ui_hideSettingsAndLayer(anim::type animated) {
if (_layer) { if (animated == anim::type::instant) {
destroyLayer();
} else if (_layer) {
_layer->hideAll(animated); _layer->hideAll(animated);
if (animated == anim::type::instant) {
destroyLayer();
}
} }
} }

View File

@ -285,7 +285,9 @@ void SeparatePanel::ensureLayerCreated() {
_layer->resize(size); _layer->resize(size);
}, _layer->lifetime()); }, _layer->lifetime());
_layer->hideFinishEvents( _layer->hideFinishEvents(
) | rpl::start_with_next([=]{ ) | rpl::filter([=] {
return _layer != nullptr; // Last hide finish is sent from destructor.
}) | rpl::start_with_next([=] {
if (Ui::InFocusChain(_layer)) { if (Ui::InFocusChain(_layer)) {
setFocus(); setFocus();
} }

View File

@ -397,7 +397,7 @@ void LayerStackWidget::hideCurrent(anim::type animated) {
} }
void LayerStackWidget::hideLayers(anim::type animated) { void LayerStackWidget::hideLayers(anim::type animated) {
startAnimation([] {}, [this] { startAnimation([] {}, [&] {
clearLayers(); clearLayers();
}, Action::HideLayer, animated); }, Action::HideLayer, animated);
} }