Skip to content

Commit

Permalink
Fix crash when all GPU panels are open but the CPU panel is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
romner-set committed May 22, 2023
1 parent 8c96bd5 commit 842c761
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/btop_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ namespace Cpu {

namespace Gpu {
int width_p = 100, height_p = 32;
int min_width = 41, min_height = 9;
int min_width = 41, min_height = 11;
int width = 41, height;
vector<int> x_vec = {}, y_vec = {}, b_height_vec = {};
int b_width;
Expand Down Expand Up @@ -1975,7 +1975,7 @@ namespace Draw {
redraw[i] = true;

width = Term::width;
height = max(min_height, Cpu::shown ? Cpu::height : (int)ceil((double)Term::height * height_p / 100));
height = max(min_height, Cpu::shown ? Cpu::height : (int)ceil((double)Term::height * height_p/Gpu::shown / 100));
height += (height+Cpu::height == Term::height-1);
x_vec[i] = 1; y_vec[i] = 1 + i*height + (not Config::getB("cpu_bottom"))*Cpu::shown*Cpu::height;
box[i] = createBox(x_vec[i], y_vec[i], width, height, Theme::c("cpu_box"), true, std::string("gpu") + (char)(shown_panels[i]+'0'), "", (shown_panels[i]+5)%10); // TODO gpu_box
Expand Down

0 comments on commit 842c761

Please sign in to comment.