diff --git a/Telegram/SourceFiles/mtproto/mtp_instance.cpp b/Telegram/SourceFiles/mtproto/mtp_instance.cpp index 55aa692e0..fb7fe79c6 100644 --- a/Telegram/SourceFiles/mtproto/mtp_instance.cpp +++ b/Telegram/SourceFiles/mtproto/mtp_instance.cpp @@ -102,8 +102,7 @@ public: void completedKeyDestroy(ShiftedDcId shiftedDcId); void clearKilledSessions(); - - ~Private(); + void prepareToDestroy(); private: bool hasAuthorization(); @@ -1189,7 +1188,7 @@ void Instance::Private::clearGlobalHandlers() { setSessionResetHandler(base::lambda()); } -Instance::Private::~Private() { +void Instance::Private::prepareToDestroy() { for (auto &session : base::take(_sessions)) { session.second->kill(); } @@ -1371,6 +1370,8 @@ void Instance::onClearKilledSessions() { _private->clearKilledSessions(); } -Instance::~Instance() = default; +Instance::~Instance() { + _private->prepareToDestroy(); +} } // namespace MTP