2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Fix crash when switching two columns at once.

This commit is contained in:
John Preston
2017-11-13 10:00:38 +04:00
parent 8355722f4e
commit 534b578598
2 changed files with 7 additions and 2 deletions

View File

@@ -586,7 +586,7 @@ bool WrapWidget::showInternal(
not_null<Window::SectionMemento*> memento,
const Window::SectionShow &params) {
if (auto infoMemento = dynamic_cast<Memento*>(memento.get())) {
if (infoMemento->stackSize() > 1) {
if (!_controller || infoMemento->stackSize() > 1) {
return false;
}
auto content = infoMemento->content();
@@ -606,10 +606,14 @@ bool WrapWidget::showInternal(
std::unique_ptr<Window::SectionMemento> WrapWidget::createMemento() {
auto stack = std::vector<std::unique_ptr<ContentMemento>>();
stack.reserve(_historyStack.size() + 1);
for (auto &stackItem : _historyStack) {
for (auto &stackItem : base::take(_historyStack)) {
stack.push_back(std::move(stackItem.section));
}
stack.push_back(_content->createMemento());
// We're not in valid state anymore and supposed to be destroyed.
_controller = nullptr;
return std::make_unique<Memento>(std::move(stack));
}