Fix possible crash on MTP::Instance shutdown.
This commit is contained in:
parent
2fb7bdc803
commit
d57aa2a1f6
|
@ -557,13 +557,22 @@ void Session::tryToReceive() {
|
||||||
if (messages.empty()) {
|
if (messages.empty()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
const auto guard = QPointer<Session>(this);
|
||||||
|
const auto instance = QPointer<Instance>(_instance);
|
||||||
|
const auto main = (_shiftedDcId == BareDcId(_shiftedDcId));
|
||||||
for (const auto &message : messages) {
|
for (const auto &message : messages) {
|
||||||
if (message.requestId) {
|
if (message.requestId) {
|
||||||
_instance->processCallback(message);
|
instance->processCallback(message);
|
||||||
} else if (_shiftedDcId == BareDcId(_shiftedDcId)) {
|
} else if (main) {
|
||||||
// Process updates only in main session.
|
// Process updates only in main session.
|
||||||
_instance->processUpdate(message);
|
instance->processUpdate(message);
|
||||||
}
|
}
|
||||||
|
if (!instance) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!guard) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue