returns a process that's in the hidden list, or the top-level process if they're all hidden; returns an invalid process if the list is empty
| 133 | // they're all hidden; returns an invalid process if the list is empty |
| 134 | // |
| 135 | InterestingProcess findInterestingProcessInTrees(const env::Process& root) |
| 136 | { |
| 137 | // Certain process names we wish to "hide" for aesthetic reason: |
| 138 | static const std::vector<QString> hiddenList = { |
| 139 | QFileInfo(QCoreApplication::applicationFilePath()).fileName(), "conhost.exe"}; |
| 140 | |
| 141 | if (root.children().empty()) { |
| 142 | return {}; |
| 143 | } |
| 144 | |
| 145 | auto isHidden = [&](auto&& p) { |
| 146 | for (auto& h : hiddenList) { |
| 147 | if (p.name().contains(h, Qt::CaseInsensitive)) { |
| 148 | return true; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | return false; |
| 153 | }; |
| 154 | |
| 155 | for (auto&& p : root.children()) { |
| 156 | if (!isHidden(p)) { |
| 157 | env::HandlePtr h = p.openHandleForWait(); |
| 158 | if (h) { |
| 159 | return {p, Interest::Strong, std::move(h)}; |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | auto r = findInterestingProcessInTrees(p); |
| 164 | if (r.interest == Interest::Strong) { |
| 165 | return r; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | // everything is hidden, just pick the first one that can be used |
| 170 | return findRandomProcess(root); |
| 171 | } |
| 172 | |
| 173 | void dump(const env::Process& p, int indent) |
| 174 | { |
no test coverage detected