mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix possible crash in pinned message deletion.
This commit is contained in:
parent
64dcae3174
commit
a14dbffb65
1 changed files with 15 additions and 6 deletions
|
@ -6607,12 +6607,21 @@ void HistoryWidget::checkPinnedBarState() {
|
||||||
std::move(pinnedRefreshed),
|
std::move(pinnedRefreshed),
|
||||||
std::move(markupRefreshed)
|
std::move(markupRefreshed)
|
||||||
) | rpl::map([=](Ui::MessageBarContent &&content, bool, HistoryItem*) {
|
) | rpl::map([=](Ui::MessageBarContent &&content, bool, HistoryItem*) {
|
||||||
if (!content.title.isEmpty() || !content.text.empty()) {
|
const auto id = (!content.title.isEmpty() || !content.text.empty())
|
||||||
_list->setShownPinned(
|
? _pinnedTracker->currentMessageId().message
|
||||||
session().data().message(
|
: FullMsgId();
|
||||||
_pinnedTracker->currentMessageId().message));
|
if (const auto list = _list.data()) {
|
||||||
} else {
|
// Sometimes we get here with non-empty content and id of
|
||||||
_list->setShownPinned(nullptr);
|
// message that is being deleted right now. We get here in
|
||||||
|
// the moment when _itemRemoved was already fired (so in
|
||||||
|
// the _list the _pinnedItem is already cleared) and the
|
||||||
|
// MessageUpdate::Flag::Destroyed being fired right now,
|
||||||
|
// so the message is still in Data::Session. So we need to
|
||||||
|
// call data().message() async, otherwise we get a nearly-
|
||||||
|
// destroyed message from it and save the pointer in _list.
|
||||||
|
crl::on_main(list, [=] {
|
||||||
|
list->setShownPinned(session().data().message(id));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return std::move(content);
|
return std::move(content);
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Add table
Reference in a new issue