| 1037 | } |
| 1038 | |
| 1039 | void DAPDebugger::updateThreadList(int curr, const dap::array<dap::Thread> &threads) |
| 1040 | { |
| 1041 | d->threadSelector->clear(); |
| 1042 | int currIdx = -1; |
| 1043 | for (const auto &e : threads) { |
| 1044 | QString itemText = "#" + QString::number(e.id) + " " + e.name.c_str(); |
| 1045 | d->threadSelector->addItem(itemText); |
| 1046 | if (curr == e.id) |
| 1047 | currIdx = d->threadSelector->count() - 1; |
| 1048 | } |
| 1049 | if (currIdx != -1) |
| 1050 | d->threadSelector->setCurrentIndex(currIdx); |
| 1051 | else if (!threads.empty()) { |
| 1052 | d->threadSelector->setCurrentIndex(0); |
| 1053 | int threadId = static_cast<int>(threads.at(0).id); |
| 1054 | switchCurrentThread(threadId); |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | void DAPDebugger::switchCurrentThread(int threadId) |
| 1059 | { |