Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

retain meter state when it is reinit'ed in the Setup screen

git-svn-id: https://htop.svn.sourceforge.net/svnroot/htop/trunk@221 63cc0a6c-1f0e-0410-841e-f6a342073da8
  • Loading branch information...
commit 9f50516202d11ec4ff6dfce3754591477893a3f4 1 parent a330666
loderunner authored

Showing 2 changed files with 10 additions and 6 deletions. Show diff stats Hide diff stats

  1. +8 5 CPUMeter.c
  2. +2 1  Meter.c
13 CPUMeter.c
@@ -124,12 +124,15 @@ static void CPUMeter_display(Object* cast, RichString* out) {
124 124
125 125 static void AllCPUsMeter_init(Meter* this) {
126 126 int cpus = this->pl->cpuCount;
127   - this->drawData = malloc(sizeof(Meter*) * cpus);
  127 + if (!this->drawData)
  128 + this->drawData = calloc(sizeof(Meter*), cpus);
128 129 Meter** meters = (Meter**) this->drawData;
129   - for (int i = 0; i < cpus; i++)
130   - meters[i] = Meter_new(this->pl, i+1, &CPUMeter);
131   - this->h = cpus;
132   - this->mode = BAR_METERMODE;
  130 + for (int i = 0; i < cpus; i++) {
  131 + if (!meters[i])
  132 + meters[i] = Meter_new(this->pl, i+1, &CPUMeter);
  133 + meters[i]->type->init(meters[i]);
  134 + }
  135 + this->h = Meter_modes[this->mode]->h;
133 136 }
134 137
135 138 static void AllCPUsMeter_done(Meter* this) {
3  Meter.c
@@ -155,8 +155,9 @@ Meter* Meter_new(ProcessList* pl, int param, MeterType* type) {
155 155 }
156 156
157 157 void Meter_delete(Object* cast) {
  158 + if (!cast)
  159 + return;
158 160 Meter* this = (Meter*) cast;
159   - assert (this != NULL);
160 161 if (this->type->done) {
161 162 this->type->done(this);
162 163 }

0 comments on commit 9f50516

Please sign in to comment.
Something went wrong with that request. Please try again.