jorgeartware / key-mon

Automatically exported from code.google.com/p/key-mon
Apache License 2.0
0 stars 0 forks source link

Command-line options take precedence over interactive settings #99

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run: key-mon --meta
2. Right-click on the key-mon window and open the Settings dialog.
3. Toggle the "Meta" checkbox.

Wanna have even more fun? Try toggling the settings after running:
key-mon --noctrl --nomouse --noalt --noshift --meta

Well, this was a pain to track down. The explanation for this bug is quite 
convoluted:
1. key_mon.create_options() creates those options, and set the default values 
for them.
2. Options.OptionItem.set_from_optparse() stores the command-line parameters 
with self._set_temp_value(), but only if they are different from the default 
value.
3. settings.CommonFrame correctly calls self._update_option(), which correctly 
calls self.settings.options.save() and emit the 'settings-changed' signal.
4. options.OptionItem.get_value(), returns self._temp_value if it is set, 
ignoring self._value.

This leads to some pretty weird behaviors.

Extreme case #1:
  key-mon --noctrl --nomouse --noalt --noshift --meta
All checkboxes from the settings dialog will be ignored, even though they will 
be correctly saved to ~/.config/key-mon/config

Extreme case #2:
  key-mon --ctrl --mouse --alt --shift --nometa
Here, all these explicit command-line parameters are ignored, as they are the 
same as their default values. That means key-mon will load whatever setting it 
has from the config file, ignoring the parameters.

I know you've put a lot of effort into OptionItem, but wouldn't be the case to 
simplify it? Maybe use 'argparse' module from Python 2.7+, or maybe storing 
only one value (instead of that _temp_value).

A similar (and slightly unrelated) weird behavior was described issue 74, but 
for different reasons (as far as I understand).

Original issue reported on code.google.com by denilsonsa on 12 Oct 2011 at 12:03

GoogleCodeExporter commented 9 years ago
Thanks for looking at this.   The support for adding config settings was done 
by someone else and it was never a perfect fit. 

I've fiddled with the _temp_value so that it gets overridden when there's a 
user change.

Original comment by scottaki...@gmail.com on 13 Oct 2011 at 2:24

GoogleCodeExporter commented 9 years ago
This fix r9b06df97da0c breaks command-line options, see Issue 114, also blocked 
thereby.

Original comment by livibet...@gmail.com on 28 Apr 2012 at 10:29

GoogleCodeExporter commented 9 years ago
This is fixed in ra38ac29ff286. (Related  Issue 116 and Issue 109), closing.

Original comment by livibet...@gmail.com on 2 Jul 2012 at 5:49