summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJos Dehaes <jos.dehaes@gmail.com>2021-10-06 22:38:19 +0200
committerJos Dehaes <jos.dehaes@gmail.com>2021-10-06 22:38:19 +0200
commit7e5a808c731772bab35204f2e286975fca334f54 (patch)
tree188ee33f85d2ca0ec06fa572f4a0502358804e40
parent9c9da4606b3f93c0701b820a875fb3db5d0c3daf (diff)
avoid details crash
-rw-r--r--src/btop_draw.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/btop_draw.cpp b/src/btop_draw.cpp
index 2f3eabc..609a336 100644
--- a/src/btop_draw.cpp
+++ b/src/btop_draw.cpp
@@ -1313,14 +1313,15 @@ namespace Proc {
if (item_fit >= 7) out += cjust(to_string(detailed.entry.threads), item_width);
if (item_fit >= 8) out += cjust(to_string(detailed.entry.p_nice), item_width);
-
- const double mem_p = (double)detailed.mem_bytes.back() * 100 / totalMem;
- string mem_str = to_string(mem_p);
- mem_str.resize((mem_p < 10 or mem_p >= 100 ? 3 : 4));
- out += Mv::to(d_y + 4, d_x + 1) + Theme::c("title") + Fx::b + rjust((item_fit > 4 ? "Memory: " : "M:") + mem_str + "% ", (d_width / 3) - 2)
- + Theme::c("inactive_fg") + Fx::ub + graph_bg * (d_width / 3) + Mv::l(d_width / 3)
- + Theme::c("proc_misc") + detailed_mem_graph(detailed.mem_bytes, (redraw or data_same or not alive)) + ' '
- + Theme::c("title") + Fx::b + detailed.memory;
+ if (detailed.mem_bytes.size() > 0) {
+ const double mem_p = (double)detailed.mem_bytes.back() * 100 / totalMem;
+ string mem_str = to_string(mem_p);
+ mem_str.resize((mem_p < 10 or mem_p >= 100 ? 3 : 4));
+ out += Mv::to(d_y + 4, d_x + 1) + Theme::c("title") + Fx::b + rjust((item_fit > 4 ? "Memory: " : "M:") + mem_str + "% ", (d_width / 3) - 2)
+ + Theme::c("inactive_fg") + Fx::ub + graph_bg * (d_width / 3) + Mv::l(d_width / 3)
+ + Theme::c("proc_misc") + detailed_mem_graph(detailed.mem_bytes, (redraw or data_same or not alive)) + ' '
+ + Theme::c("title") + Fx::b + detailed.memory;
+ }
}
//? Check bounds of current selection and view