diff --git a/src/btop_shared.cpp b/src/btop_shared.cpp index d7856e8..94806d5 100644 --- a/src/btop_shared.cpp +++ b/src/btop_shared.cpp @@ -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 ? "[+]─" : "[-]─") : " ├─ "); + } } \ No newline at end of file diff --git a/src/linux/btop_collect.cpp b/src/linux/btop_collect.cpp index 86514a9..e986d35 100644 --- a/src/linux/btop_collect.cpp +++ b/src/linux/btop_collect.cpp @@ -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