diff options
author | Daniel Lange <DLange@git.local> | 2022-04-02 12:30:30 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2022-04-02 12:30:30 +0200 |
commit | 0ffd772d28bdf2fb1f0ef5abbb6fff17223edee9 (patch) | |
tree | 31289e18960ad8bc31414352fb43c22c20cfd0b7 | |
parent | a2ca7583a9ba2e57eb9e9316aad52c9248aae092 (diff) |
Fix header layout and meters reset if a header column is empty
Closes #880
Patch from BenBE and cgzones
-rw-r--r-- | Settings.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -111,14 +111,21 @@ static void Settings_readMeterModes(Settings* this, const char* line, unsigned i static bool Settings_validateMeters(Settings* this) { const size_t colCount = HeaderLayout_getColumns(this->hLayout); + bool anyMeter = false; + for (size_t column = 0; column < colCount; column++) { char** names = this->hColumns[column].names; const int* modes = this->hColumns[column].modes; const size_t len = this->hColumns[column].len; - if (!names || !modes || !len) + if (!len) + continue; + + if (!names || !modes) return false; + anyMeter |= !!len; + // Check for each mode there is an entry with a non-NULL name for (size_t meterIdx = 0; meterIdx < len; meterIdx++) if (!names[meterIdx]) @@ -128,7 +135,7 @@ static bool Settings_validateMeters(Settings* this) { return false; } - return true; + return anyMeter; } static void Settings_defaultMeters(Settings* this, unsigned int initialCpuCount) { |