Issues
There are two related issues:
CFG_sync() rewrites settings file, even settings that were not changed
CFG_init() invokes CFG_sync()
That is not a very big problem for NextUI and its bundled binaries as they are always consistent among themselves. However it becomes a lot worse when a pak uses NextUI's api.c and config.c and link them statically: if such a pak built against an older version performs CFG_init() on a newer NextUI system, it would strip configuration flags unknown to the pak, reverting them to default values.
Even worse than that, if configuration flags changed semantics (e.g. RGB->RGBA conversion of 6.11), an older pak would repeatedly write back wrong values on every start, potentially moving a value out of reasonable range.
Proposal
Change an approach to configuration read and write:
CFG_init(), CFG_getX() and CFG_setX() (it if is set the same value) should not write to the settings file
- when file is being written:
- only explicitly changed settings should be written with new values
- unchanged settings should be left as-is (having the same serialized values as before the write)
- unknown values should be preserved
Issues
There are two related issues:
CFG_sync()rewrites settings file, even settings that were not changedCFG_init()invokesCFG_sync()That is not a very big problem for NextUI and its bundled binaries as they are always consistent among themselves. However it becomes a lot worse when a pak uses NextUI's
api.candconfig.cand link them statically: if such a pak built against an older version performsCFG_init()on a newer NextUI system, it would strip configuration flags unknown to the pak, reverting them to default values.Even worse than that, if configuration flags changed semantics (e.g. RGB->RGBA conversion of 6.11), an older pak would repeatedly write back wrong values on every start, potentially moving a value out of reasonable range.
Proposal
Change an approach to configuration read and write:
CFG_init(),CFG_getX()andCFG_setX()(it if is set the same value) should not write to the settings file