2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Guard click handlers that capture session data.

Click handlers invocation is done by posting on_main,
so in rare cases the session may be already destroyed.
This commit is contained in:
John Preston
2020-05-04 17:38:49 +04:00
parent 038d8f1781
commit 6adcf660f1
6 changed files with 75 additions and 30 deletions

View File

@@ -315,16 +315,19 @@ class DocumentClickHandler : public FileClickHandler {
public:
DocumentClickHandler(
not_null<DocumentData*> document,
FullMsgId context = FullMsgId())
: FileClickHandler(context)
, _document(document) {
FullMsgId context = FullMsgId());
[[nodiscard]] bool valid() const {
return !_session.empty();
}
not_null<DocumentData*> document() const {
[[nodiscard]] not_null<DocumentData*> document() const {
return _document;
}
private:
not_null<DocumentData*> _document;
const base::weak_ptr<Main::Session> _session;
const not_null<DocumentData*> _document;
};