mirror of
https://github.com/aristocratos/btop.git
synced 2024-05-10 07:23:23 +12:00
Fixed: Extra checks to avoid crash on trying to replace empty strings in tree mode
This commit is contained in:
parent
ee0945969d
commit
3796a8ccee
|
@ -140,12 +140,10 @@ namespace Proc {
|
|||
}
|
||||
|
||||
//? Recursive iteration over all children
|
||||
int children = 0;
|
||||
for (auto& p : rng::equal_range(in_procs, cur_proc.pid, rng::less{}, &proc_info::ppid)) {
|
||||
if (collapsed and not filtering) {
|
||||
cur_proc.filtered = true;
|
||||
}
|
||||
children++;
|
||||
|
||||
_tree_gen(p, in_procs, out_procs.back().children, cur_depth + 1, (collapsed or cur_proc.collapsed), filter, found, no_update, should_filter);
|
||||
|
||||
|
@ -164,11 +162,12 @@ namespace Proc {
|
|||
}
|
||||
|
||||
//? Add tree terminator symbol if it's the last child in a sub-tree
|
||||
if (children > 0 and out_procs.back().children.back().entry.get().prefix.size() >= 8 and not out_procs.back().children.back().entry.get().prefix.ends_with("]─"))
|
||||
if (out_procs.back().children.size() > 0 and out_procs.back().children.back().entry.get().prefix.size() >= 8 and not out_procs.back().children.back().entry.get().prefix.ends_with("]─"))
|
||||
out_procs.back().children.back().entry.get().prefix.replace(out_procs.back().children.back().entry.get().prefix.size() - 8, 8, " └─ ");
|
||||
|
||||
//? Add collapse/expand symbols if process have any children
|
||||
out_procs.at(cur_pos).entry.get().prefix = " │ "s * cur_depth + (children > 0 ? (cur_proc.collapsed ? "[+]─" : "[-]─") : " ├─ ");
|
||||
out_procs.at(cur_pos).entry.get().prefix = " │ "s * cur_depth + (out_procs.at(cur_pos).children.size() > 0 ? (cur_proc.collapsed ? "[+]─" : "[-]─") : " ├─ ");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1907,11 +1907,11 @@ namespace Proc {
|
|||
tree_sort(tree_procs, sorting, reverse, index, current_procs.size());
|
||||
|
||||
//? Add tree begin symbol to first item if childless
|
||||
if (tree_procs.front().children.empty())
|
||||
if (tree_procs.size() > 0 and tree_procs.front().children.empty() and tree_procs.front().entry.get().prefix.size() >= 8)
|
||||
tree_procs.front().entry.get().prefix.replace(tree_procs.front().entry.get().prefix.size() - 8, 8, " ┌─ ");
|
||||
|
||||
//? Add tree terminator symbol to last item if childless
|
||||
if (tree_procs.back().children.empty())
|
||||
if (tree_procs.size() > 0 and tree_procs.back().children.empty() and tree_procs.back().entry.get().prefix.size() >= 8)
|
||||
tree_procs.back().entry.get().prefix.replace(tree_procs.back().entry.get().prefix.size() - 8, 8, " └─ ");
|
||||
|
||||
//? Final sort based on tree index
|
||||
|
|
Loading…
Reference in a new issue