Don't append comments to end of settings in config.cfg

Andrew Heard shared this idea 2 months ago

This is a warning rather than an idea or suggestion - just an observation I found out the hard way that I'd like to share with others that may by mistake do what I did...

As background: Locus has a text file config.cfg that stores a heap of settings. Generally the average Locus user has no need to change these settings from their defaults. Comment lines start with a hash # character in the first column.

I had this idea I would add a comment onto the end of each setting I changed to make it easy with a text editor to later find all my changes. For example:


DO NOT add comments onto the end of a setting as in the screen cap above. Place the comment on its own line if you need to have your own comment as below:


When Locus reads the file it does not parse the comment correctly, and in subsequent re-write of the file at app exit the setting will become zero (0) in most of cases. Then the next time you run Locus "bad things will happen" without warning of malformed/ out-of-range settings. In my case all buttons, menus, ruler disappeared. It took a day to figure out it was related to my new comments.

Comments (3)


@menion - after further testing for this topic I find any user comment on its own line or even editing of existing comment is overwritten when Locus exits. So in fact it is not possible for the user to add comments. I know in other topics you would like to eliminate this file altogether, so rather than making a further suggestion like "allow user to add comments to config file" I will just make this note for other users to be aware.



hmm, understand. The file is overwritten everytime you exit Locus Map app, so comments should be always immediately lost.

Fact that values are incorrectly handled in case you place a comment in the same line as value makes sense (at least to me) because everything after "=" character is trying to convert to the number.

I may only hope, that no one from config-editing-users will have these ideas, but thanks for pointing on this "issue". I've added warning on this into header of generated config.cfg, at least.


If anyone is as silly as me with the same "issue" and search for help, at least this may be of some use to them. It is a little different to other INI & YAML files where comments are generally preserved in re-write.