mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
fix: crash if deleted when taking shot
This commit is contained in:
parent
4e9443e200
commit
f583732688
1 changed files with 16 additions and 1 deletions
|
@ -237,7 +237,7 @@ QImage addPadding(const QImage &original, int padding) {
|
|||
QImage Make(not_null<QWidget*> box, const ShotConfig &config) {
|
||||
const auto controller = config.controller;
|
||||
const auto st = config.st;
|
||||
const auto messages = config.messages;
|
||||
auto messages = config.messages;
|
||||
|
||||
if (messages.empty()) {
|
||||
return {};
|
||||
|
@ -252,6 +252,21 @@ QImage Make(not_null<QWidget*> box, const ShotConfig &config) {
|
|||
box->update();
|
||||
});
|
||||
|
||||
// remove deleted messages
|
||||
messages.erase(
|
||||
std::ranges::remove_if(
|
||||
messages,
|
||||
[=](const auto &message)
|
||||
{
|
||||
return !message || !controller->session().data().message(message->fullId());
|
||||
}).begin(),
|
||||
messages.end()
|
||||
);
|
||||
|
||||
if (messages.empty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::unordered_map<not_null<HistoryItem*>, std::shared_ptr<HistoryView::Element>> createdViews;
|
||||
createdViews.reserve(messages.size());
|
||||
for (const auto &message : messages) {
|
||||
|
|
Loading…
Add table
Reference in a new issue