Fix crash in "Copy Topic Link" action.

This commit is contained in:
John Preston
2025-11-15 17:54:08 +04:00
parent 1e45692ba4
commit a9cf5dd6f2

View File

@@ -1074,12 +1074,15 @@ void Filler::addTopicLink() {
return;
}
const auto controller = _controller;
const auto weak = base::make_weak(_topic);
_addAction(tr::lng_context_copy_topic_link(tr::now), [=] {
const auto link = Info::Profile::TopicLink(_topic, true);
QGuiApplication::clipboard()->setText(link);
controller->showToast(channel->hasUsername()
? tr::lng_channel_public_link_copied(tr::now)
: tr::lng_context_about_private_link(tr::now));
if (const auto strong = weak.get()) {
const auto link = Info::Profile::TopicLink(strong, true);
QGuiApplication::clipboard()->setText(link);
controller->showToast(channel->hasUsername()
? tr::lng_channel_public_link_copied(tr::now)
: tr::lng_context_about_private_link(tr::now));
}
}, &st::menuIconCopy);
}