2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Fix crash on quit in sponsored messages.

This commit is contained in:
John Preston
2024-04-24 16:35:05 +04:00
parent 17b7db6219
commit 3da51b1bc9
3 changed files with 16 additions and 3 deletions

View File

@@ -37,9 +37,20 @@ SponsoredMessages::SponsoredMessages(not_null<Main::Session*> session)
}
SponsoredMessages::~SponsoredMessages() {
for (const auto &request : _requests) {
Expects(_data.empty());
Expects(_requests.empty());
Expects(_viewRequests.empty());
}
void SponsoredMessages::clear() {
_lifetime.destroy();
for (const auto &request : base::take(_requests)) {
_session->api().request(request.second.requestId).cancel();
}
for (const auto &request : base::take(_viewRequests)) {
_session->api().request(request.second.requestId).cancel();
}
base::take(_data);
}
void SponsoredMessages::clearOldRequests() {

View File

@@ -80,8 +80,6 @@ public:
};
using RandomId = QByteArray;
explicit SponsoredMessages(not_null<Main::Session*> session);
SponsoredMessages(const SponsoredMessages &other) = delete;
SponsoredMessages &operator=(const SponsoredMessages &other) = delete;
~SponsoredMessages();
[[nodiscard]] bool canHaveFor(not_null<History*> history) const;
@@ -104,6 +102,8 @@ public:
[[nodiscard]] auto createReportCallback(const FullMsgId &fullId)
-> Fn<void(SponsoredReportResult::Id, Fn<void(SponsoredReportResult)>)>;
void clear();
private:
using OwnedItem = std::unique_ptr<HistoryItem, HistoryItem::Destroyer>;
struct Entry {