fix temp meter duplication

This commit is contained in:
Timofey Gelazoniya 2022-06-10 20:12:16 +03:00
parent 637550ed51
commit 765e3de1e7
Signed by: zeldon
GPG Key ID: 047886915281DD2A
1 changed files with 5 additions and 73 deletions

View File

@ -665,81 +665,13 @@ static bool Settings_read(Settings *this, const char *fileName, unsigned int ini
} }
fclose(fd); fclose(fd);
if (didReadMeters) if (!didReadMeters || !Settings_validateMeters(this))
{
if (didReadMeters)
{
#if defined FORCE_TEMP_METER || defined FORCE_FREQ_METER
int ftidx = this->hColumns[1].len;
size_t realloc_len = ftidx;
#ifdef FORCE_TEMP_METER
uint8_t t_det = 0;
#endif
#ifdef FORCE_FREQ_METER
uint8_t f_det = 0;
#endif
char **cnames = this->hColumns[1].names;
for (int i = 0; i < ftidx; ++i)
{
#ifdef FORCE_TEMP_METER
if (strcmp("Temp", cnames[i]) == 0)
{
t_det = 1;
break;
}
#endif
#ifdef FORCE_FREQ_METER
if (strcmp("Freq", cnames[i]) == 0)
{
f_det = 1;
break;
}
#endif
}
#ifdef FORCE_TEMP_METER
if (!t_det)
{
++realloc_len;
}
#endif
#ifdef FORCE_FREQ_METER
if (!f_det)
{
++realloc_len;
}
#endif
this->hColumns[1].names = xReallocArray(this->hColumns[1].names, realloc_len + 1, sizeof(char *));
this->hColumns[1].modes = xReallocArray(this->hColumns[1].modes, realloc_len, sizeof(int));
#ifdef FORCE_TEMP_METER
if (!t_det)
{
this->hColumns[1].names[ftidx] = xStrdup("Temp");
this->hColumns[1].modes[ftidx++] = TEXT_METERMODE;
}
#endif
#ifdef FORCE_FREQ_METER
if (!f_det)
{
this->hColumns[1].names[ftidx] = xStrdup("Freq");
this->hColumns[1].modes[ftidx++] = TEXT_METERMODE;
}
#endif
this->hColumns[1].len = ftidx;
#endif
}
else
{
Settings_defaultMeters(this, initialCpuCount); Settings_defaultMeters(this, initialCpuCount);
}
if (!this->nScreens) if (!this->nScreens)
Settings_defaultScreens(this); Settings_defaultScreens(this);
return didReadAny; return didReadAny;
} }
}
static void writeFields(FILE *fd, const ProcessField *fields, Hashtable *columns, bool byName, char separator) static void writeFields(FILE *fd, const ProcessField *fields, Hashtable *columns, bool byName, char separator)
{ {