mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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()) {
|
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…
Add table
Reference in a new issue