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:
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user