diff --git a/Telegram/SourceFiles/mtproto/mtp_instance.cpp b/Telegram/SourceFiles/mtproto/mtp_instance.cpp index 0af0dc90d7..411d70c45e 100644 --- a/Telegram/SourceFiles/mtproto/mtp_instance.cpp +++ b/Telegram/SourceFiles/mtproto/mtp_instance.cpp @@ -1454,15 +1454,19 @@ Session *Instance::Private::removeSession(ShiftedDcId shiftedDcId) { not_null Instance::Private::getThreadForDc( ShiftedDcId shiftedDcId) { - static const auto EnsureStarted = [](std::unique_ptr &thread) { + static const auto EnsureStarted = []( + std::unique_ptr &thread, + auto name) { if (!thread) { thread = std::make_unique(); + thread->setObjectName(name()); thread->start(); } return thread.get(); }; static const auto FindOne = []( std::vector> &threads, + const char *prefix, int index, bool shift) { Expects(!threads.empty()); @@ -1476,20 +1480,26 @@ not_null Instance::Private::getThreadForDc( if (shift) { index = (index + count / 2) % count; } - return EnsureStarted(threads[index]); + return EnsureStarted(threads[index], [=] { + return QString("MTP %1 Session (%2)").arg(prefix).arg(index); + }); }; if (shiftedDcId == BareDcId(shiftedDcId)) { - return EnsureStarted(_mainSessionThread); + return EnsureStarted(_mainSessionThread, [] { + return QString("MTP Main Session"); + }); } else if (isDownloadDcId(shiftedDcId)) { const auto index = GetDcIdShift(shiftedDcId) - kBaseDownloadDcShift; const auto composed = index + BareDcId(shiftedDcId); - return FindOne(_fileSessionThreads, composed, false); + return FindOne(_fileSessionThreads, "Download", composed, false); } else if (isUploadDcId(shiftedDcId)) { const auto index = GetDcIdShift(shiftedDcId) - kBaseUploadDcShift; const auto composed = index + BareDcId(shiftedDcId); - return FindOne(_fileSessionThreads, composed, true); + return FindOne(_fileSessionThreads, "Upload", composed, true); } - return EnsureStarted(_otherSessionsThread); + return EnsureStarted(_otherSessionsThread, [] { + return QString("MTP Other Session"); + }); } void Instance::Private::scheduleKeyDestroy(ShiftedDcId shiftedDcId) {