MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / findInterestingProcessInTrees

Function findInterestingProcessInTrees

src/processrunner.cpp:135–171  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

133// they're all hidden; returns an invalid process if the list is empty
134//
135InterestingProcess 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
173void dump(const env::Process& p, int indent)
174{

Callers 1

getInterestingProcessFunction · 0.85

Calls 6

isHiddenFunction · 0.85
findRandomProcessFunction · 0.85
childrenMethod · 0.80
openHandleForWaitMethod · 0.80
emptyMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected