mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Fix possible crash on MTP::Instance shutdown.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user