mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Fix possible crash on MTP::Instance shutdown.
This commit is contained in:
parent
2fb7bdc803
commit
d57aa2a1f6
1 changed files with 12 additions and 3 deletions
|
@ -557,13 +557,22 @@ void Session::tryToReceive() {
|
|||
if (messages.empty()) {
|
||||
break;
|
||||
}
|
||||
const auto guard = QPointer<Session>(this);
|
||||
const auto instance = QPointer<Instance>(_instance);
|
||||
const auto main = (_shiftedDcId == BareDcId(_shiftedDcId));
|
||||
for (const auto &message : messages) {
|
||||
if (message.requestId) {
|
||||
_instance->processCallback(message);
|
||||
} else if (_shiftedDcId == BareDcId(_shiftedDcId)) {
|
||||
instance->processCallback(message);
|
||||
} else if (main) {
|
||||
// Process updates only in main session.
|
||||
_instance->processUpdate(message);
|
||||
instance->processUpdate(message);
|
||||
}
|
||||
if (!instance) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!guard) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue