Fix crash in layer stack unwinding.

This commit is contained in:
John Preston 2017-06-28 10:06:52 +03:00
parent 75fdd5315f
commit 5b4f70ff96
1 changed files with 9 additions and 0 deletions

View File

@ -717,6 +717,15 @@ void LayerStackWidget::onLayerDestroyed(QObject *obj) {
} }
LayerStackWidget::~LayerStackWidget() { LayerStackWidget::~LayerStackWidget() {
// We must destroy all layers before we destroy LayerStackWidget.
// Some layers in destructor call layer-related methods, like hiding
// other layers, that call methods of LayerStackWidget and access
// its fields, so if it is destroyed already everything crashes.
for (auto layer : base::take(_layers)) {
layer->setClosing();
layer->hide();
delete layer;
}
if (App::wnd()) App::wnd()->noLayerStack(this); if (App::wnd()) App::wnd()->noLayerStack(this);
} }