Use MainPanel type in State struct

The State struct holds a pointer to the main process panel.
Use the distinct MainPanel type, to improve maintainability regrading
its usage.
This avoids usages of down-casts from Panel to MainPanel, only up-casts
from MainPanel to Panel are now required.
This commit is contained in:
Christian Göttsche
2021-02-05 14:12:49 +01:00
parent fd1ad863dc
commit fd4e6b432b
5 changed files with 48 additions and 46 deletions

View File

@ -130,9 +130,7 @@ void Platform_done(void) {
}
static Htop_Reaction Platform_actionSetIOPriority(State* st) {
Panel* panel = st->panel;
const LinuxProcess* p = (const LinuxProcess*) Panel_getSelected(panel);
const LinuxProcess* p = (const LinuxProcess*) Panel_getSelected((Panel*)st->mainPanel);
if (!p)
return HTOP_OK;
@ -141,7 +139,7 @@ static Htop_Reaction Platform_actionSetIOPriority(State* st) {
const void* set = Action_pickFromVector(st, ioprioPanel, 21, true);
if (set) {
IOPriority ioprio2 = IOPriorityPanel_getIOPriority(ioprioPanel);
bool ok = MainPanel_foreachProcess((MainPanel*)panel, LinuxProcess_setIOPriority, (Arg) { .i = ioprio2 }, NULL);
bool ok = MainPanel_foreachProcess(st->mainPanel, LinuxProcess_setIOPriority, (Arg) { .i = ioprio2 }, NULL);
if (!ok) {
beep();
}