diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2023-01-07 18:25:24 +0100 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2023-01-10 18:59:25 +0100 |
commit | 490cedba04aef27c2a3c0bc3a9d6190b05082717 (patch) | |
tree | 892daef852bfb146ec8c6aa4cb6e54e525b48b3b /Settings.c | |
parent | d97cf58261d340922c85bee9b9e1670b4f88eafc (diff) |
Handle invalid process columns from configuration
Skip over invalid process columns, such that later columns are displayed
fine.
Replace invalid sort key identifiers with the default sort column PID.
Diffstat (limited to 'Settings.c')
-rw-r--r-- | Settings.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -262,10 +262,9 @@ static void ScreenSettings_readFields(ScreenSettings* ss, Hashtable* columns, co } int id = toFieldIndex(columns, ids[i]); if (id >= 0) - ss->fields[j] = id; + ss->fields[j++] = id; if (id > 0 && id < LAST_PROCESSFIELD) ss->flags |= Process_fields[id].flags; - j++; } String_freeArray(ids); } @@ -480,11 +479,15 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini } else if (strncmp(option[0], "screen:", 7) == 0) { screen = Settings_newScreen(this, &(const ScreenDefaults) { .name = option[0] + 7, .columns = option[1] }); } else if (String_eq(option[0], ".sort_key")) { - if (screen) - screen->sortKey = toFieldIndex(this->dynamicColumns, option[1]); + if (screen) { + int key = toFieldIndex(this->dynamicColumns, option[1]); + screen->sortKey = key > 0 ? key : PID; + } } else if (String_eq(option[0], ".tree_sort_key")) { - if (screen) - screen->treeSortKey = toFieldIndex(this->dynamicColumns, option[1]); + if (screen) { + int key = toFieldIndex(this->dynamicColumns, option[1]); + screen->treeSortKey = key > 0 ? key : PID; + } } else if (String_eq(option[0], ".sort_direction")) { if (screen) screen->direction = atoi(option[1]); |