Fix crash in poll view destruction.
This commit is contained in:
parent
f9be304e54
commit
d34eabdc11
3 changed files with 23 additions and 5 deletions
|
@ -55,7 +55,7 @@ enum class MediaInBubbleState {
|
|||
|
||||
class Media : public Object {
|
||||
public:
|
||||
Media(not_null<Element*> parent) : _parent(parent) {
|
||||
explicit Media(not_null<Element*> parent) : _parent(parent) {
|
||||
}
|
||||
|
||||
[[nodiscard]] not_null<History*> history() const;
|
||||
|
@ -284,7 +284,7 @@ protected:
|
|||
virtual void playAnimation(bool autoplay) {
|
||||
}
|
||||
|
||||
not_null<Element*> _parent;
|
||||
const not_null<Element*> _parent;
|
||||
MediaInBubbleState _inBubbleState = MediaInBubbleState::None;
|
||||
|
||||
};
|
||||
|
|
|
@ -485,11 +485,27 @@ void Poll::updateRecentVoters() {
|
|||
ranges::equal_to(),
|
||||
&RecentVoter::user);
|
||||
if (changed) {
|
||||
_recentVoters = ranges::view::all(
|
||||
auto updated = ranges::view::all(
|
||||
sliced
|
||||
) | ranges::views::transform([](not_null<UserData*> user) {
|
||||
return RecentVoter{ user };
|
||||
}) | ranges::to_vector;
|
||||
const auto has = hasHeavyPart();
|
||||
if (has) {
|
||||
for (auto &voter : updated) {
|
||||
const auto i = ranges::find(
|
||||
_recentVoters,
|
||||
voter.user,
|
||||
&RecentVoter::user);
|
||||
if (i != end(_recentVoters)) {
|
||||
voter.userpic = std::move(i->userpic);
|
||||
}
|
||||
}
|
||||
}
|
||||
_recentVoters = std::move(updated);
|
||||
if (has && !hasHeavyPart()) {
|
||||
_parent->checkHeavyPart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,11 +80,13 @@ Sticker::Sticker(
|
|||
|
||||
Sticker::~Sticker() {
|
||||
if (_lottie || _dataMedia) {
|
||||
unloadLottie();
|
||||
if (_lottie) {
|
||||
unloadLottie();
|
||||
}
|
||||
if (_dataMedia) {
|
||||
_data->owner().keepAlive(base::take(_dataMedia));
|
||||
_parent->checkHeavyPart();
|
||||
}
|
||||
_parent->checkHeavyPart();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue