summaryrefslogtreecommitdiffstats
path: root/Meter.c
diff options
context:
space:
mode:
authorExplorer09 <explorer09@gmail.com>2024-04-18 21:08:54 +0800
committerBenBE <BenBE@geshi.org>2024-04-20 19:36:00 +0200
commitfaaf6dd25e064f4e6e73061b15547b965b353ae5 (patch)
tree28f8e3a6e958302a29f75999039675264b9d5163 /Meter.c
parent52486dbc0f056c37b8cc81bf2f8c2830d77c7d52 (diff)
Obsolete the CUSTOM_METERMODE use in default mode
The use of CUSTOM_METERMODE value in meter default mode was a bad design. There are no meter that really has a "custom" mode to work with and currently that value serves as a useless placeholder that hides the real default mode for a meter. Replace CUSTOM_METERMODE in `defaultMode` of all meters with the real intended default modes. Currently only CPU meters and MemorySwapMeter used this, and their real defaults are BAR_METERMODE. In Meter_setMode(), remove the special treatment of `defaultMode == CUSTOM_METERMODE`, Meter_setMode() still calls the `updateMode` function for custom treatment when it's present for a meter class. As CUSTOM_METERMODE is obsolete from `defaultMode`, the init functions of CPU meters and MemorySwapMeter need to be adjusted to avoid incomplete initialization (Meter.draw function bring NULL). Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Diffstat (limited to 'Meter.c')
-rw-r--r--Meter.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/Meter.c b/Meter.c
index 938b907b..1fc7e9db 100644
--- a/Meter.c
+++ b/Meter.c
@@ -122,11 +122,10 @@ void Meter_setMode(Meter* this, int modeIndex) {
}
assert(modeIndex < LAST_METERMODE);
- if (Meter_defaultMode(this) == CUSTOM_METERMODE) {
+ if (Meter_updateModeFn(this)) {
+ assert(Meter_drawFn(this));
this->draw = Meter_drawFn(this);
- if (Meter_updateModeFn(this)) {
- Meter_updateMode(this, modeIndex);
- }
+ Meter_updateMode(this, modeIndex);
} else {
assert(modeIndex >= 1);
free(this->drawData.values);

© 2014-2024 Faster IT GmbH | imprint | privacy policy