Patch by Moritz Venn:
authorFelix Domke <tmbinc@elitedvb.net>
Wed, 11 Mar 2009 07:06:04 +0000 (08:06 +0100)
committerFelix Domke <tmbinc@elitedvb.net>
Wed, 11 Mar 2009 07:06:04 +0000 (08:06 +0100)
The current implementation of ConfigNumber.isChanged (the one inherited from ConfigElement) does not work properly as it will - at least for unsaved values - always returns True.
This is obvious if you just take a look at the datatypes since value is an int and default is a string (because ConfigNumber is a modified ConfigText).

To resolve this issue one can either compare self.tostring(self.value) or self.text to self.default but the former seems to be the more logical approach.
The attached patch does override the method in ConfigNumber with the proposed fix.

lib/python/Components/config.py

index 4cc40633047c52a182393e22e33220edde435bf0..24d39cbaeee8659b4553a506544a528e2bd9623a 100755 (executable)
@@ -1029,6 +1029,13 @@ class ConfigNumber(ConfigText):
        value = property(getValue, setValue)
        _value = property(getValue, setValue)
 
+       def isChanged(self):
+               sv = self.saved_value
+               strv = self.tostring(self.value)
+               if sv is None and strv == self.default:
+                       return False
+               return strv != sv
+
        def conform(self):
                pos = len(self.text) - self.marked_pos
                self.text = self.text.lstrip("0")