Closed beta 1000014001: fixed crash in MTP destructor.

Some of MTP::Instance::Private fields access _instance in
destructors. All that cleanup should be performed before the
Instance::~Instance() (which invalidates _private) is called.
This commit is contained in:
John Preston 2017-02-25 20:55:11 +03:00
parent bcec2f6b84
commit d1e37864ac

View file

@ -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<void(ShiftedDcId)>());
}
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