mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-13 04:37:11 +02:00
Fix couple of crashes in secondary windows.
This commit is contained in:
parent
17bb430006
commit
ec2faca145
4 changed files with 26 additions and 14 deletions
|
@ -2200,8 +2200,11 @@ void Controller::saveForum() {
|
|||
channel->inputChannel,
|
||||
MTP_bool(*_savingData.forum)
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
const auto weak = base::make_weak(this);
|
||||
channel->session().api().applyUpdates(result);
|
||||
continueSave();
|
||||
if (weak) { // todo better to be able to save in closed already box.
|
||||
continueSave();
|
||||
}
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
if (error.type() == u"CHAT_NOT_MODIFIED"_q) {
|
||||
continueSave();
|
||||
|
|
|
@ -1192,9 +1192,11 @@ void MainWidget::setInnerFocus() {
|
|||
_mainSection->setInnerFocus();
|
||||
} else if (!_hider && _thirdSection) {
|
||||
_thirdSection->setInnerFocus();
|
||||
} else {
|
||||
Assert(_dialogs != nullptr);
|
||||
} else if (_dialogs) {
|
||||
_dialogs->setInnerFocus();
|
||||
} else {
|
||||
// Maybe we're just closing a child window, content is destroyed.
|
||||
_history->setFocus();
|
||||
}
|
||||
} else if (_mainSection) {
|
||||
_mainSection->setInnerFocus();
|
||||
|
@ -1293,8 +1295,9 @@ void MainWidget::showHistory(
|
|||
}
|
||||
const auto unavailable = peer->computeUnavailableReason();
|
||||
if (!unavailable.isEmpty()) {
|
||||
Assert(isPrimary()); // windows todo
|
||||
if (params.activation != anim::activation::background) {
|
||||
if (!isPrimary()) {
|
||||
_controller->window().close();
|
||||
} else if (params.activation != anim::activation::background) {
|
||||
_controller->show(Ui::MakeInformBox(unavailable));
|
||||
_controller->window().activate();
|
||||
}
|
||||
|
@ -1950,10 +1953,9 @@ void MainWidget::showNonPremiumLimitToast(bool download) {
|
|||
});
|
||||
}
|
||||
|
||||
void MainWidget::showBackFromStack(
|
||||
const SectionShow ¶ms) {
|
||||
bool MainWidget::showBackFromStack(const SectionShow ¶ms) {
|
||||
if (preventsCloseSection([=] { showBackFromStack(params); }, params)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_stack.empty()) {
|
||||
|
@ -1963,7 +1965,7 @@ void MainWidget::showBackFromStack(
|
|||
crl::on_main(this, [=] {
|
||||
_controller->widget()->setInnerFocus();
|
||||
});
|
||||
return;
|
||||
return (_dialogs != nullptr);
|
||||
}
|
||||
auto item = std::move(_stack.back());
|
||||
_stack.pop_back();
|
||||
|
@ -1995,6 +1997,7 @@ void MainWidget::showBackFromStack(
|
|||
anim::activation::background));
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWidget::orderWidgets() {
|
||||
|
|
|
@ -152,8 +152,7 @@ public:
|
|||
const SectionShow ¶ms);
|
||||
void updateColumnLayout();
|
||||
bool stackIsEmpty() const;
|
||||
void showBackFromStack(
|
||||
const SectionShow ¶ms);
|
||||
bool showBackFromStack(const SectionShow ¶ms);
|
||||
void orderWidgets();
|
||||
QPixmap grabForShowAnimation(const Window::SectionSlideParams ¶ms);
|
||||
void checkMainSectionToLayer();
|
||||
|
|
|
@ -1660,8 +1660,9 @@ void SessionController::showForum(
|
|||
) | rpl::start_with_next([=, history = forum->history()] {
|
||||
const auto now = activeChatCurrent().owningHistory();
|
||||
const auto showHistory = !now || (now == history);
|
||||
const auto weak = base::make_weak(this);
|
||||
closeForum();
|
||||
if (showHistory) {
|
||||
if (weak && showHistory) {
|
||||
showPeerHistory(history, {
|
||||
SectionShow::Way::Backward,
|
||||
anim::type::normal,
|
||||
|
@ -1676,7 +1677,7 @@ void SessionController::closeForum() {
|
|||
if (const auto forum = _shownForum.current()) {
|
||||
const auto id = windowId();
|
||||
if (id.type == SeparateType::Forum) {
|
||||
const auto initial = id.thread->asForum();
|
||||
const auto initial = id.forum();
|
||||
if (!initial || initial == forum) {
|
||||
Core::App().closeWindow(_window);
|
||||
} else {
|
||||
|
@ -2529,7 +2530,13 @@ void SessionController::showBackFromStack(const SectionShow ¶ms) {
|
|||
return topic && topic->forum()->topicDeleted(topic->rootId());
|
||||
};
|
||||
do {
|
||||
content()->showBackFromStack(params);
|
||||
const auto empty = content()->stackIsEmpty();
|
||||
const auto shown = content()->showBackFromStack(params);
|
||||
if (empty && !shown && content()->stackIsEmpty() && bad()) {
|
||||
clearSectionStack(anim::type::instant);
|
||||
window().close();
|
||||
break;
|
||||
}
|
||||
} while (bad());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue