Acknowledged
over 1 year ago

Settings data corruption continues to be a problem

I have seen that app settings data corruption happens on many models without explanation.  This continues to be a problem.

It seems to happen more often when there is a property defined eg.

    <property id="Park" type="boolean">false</property>
but there is no corresponding <setting> for this (there doesn't need be for my application).
In this situation, the property should always be false (unless changed by the program in which it was never), but sometimes unexplainedly a true is read.
The corruption is not limited to such cases.
Has anyone else experienced this or noticed a pattern that might help identify the cause?
  • Here is the boilerplate code that I use:

        // Reading Settings
        // returns a config property as a boolean object
        function getBooleanProperty(key, initial) {
            var value = getProp(key);
            if (value != null) {
                if (value instanceof Lang.Boolean) {
                    return value;
                } else if (value instanceof Lang.String) {
                    return value.toNumber() != 0;
                }
            }
            return initial;
        }

        // returns a config property as a Float object
        function getFloatProperty(key, initial) {
            var value = getProp(key);
            if (value != null) {
                if (value instanceof Lang.Float) {
                    return value;
                }
                else {
                    return value.toFloat();
                }
            }
            return initial;
        }  

        function getColorProp(key){
            var retVal=0;
            var str=getStringProp(key);
            if (str!=null) {
                // note that this API funciton will stop parsing on the first non-hex digit
                // the function handles both upper and lower case
                retVal=str.toNumberWithBase(16);
            }
            return retVal;
        }

        // returns a config property as a Number object
        function getNumberProperty(key, initial) {
            var value = getProp(key);
            if (value != null) {
                if (value instanceof Lang.Number) {
                    return value;
                } else if (value instanceof Lang.Long || value instanceof Lang.String) {
                    return value.toNumber();
                }
            }
            return initial;
        }    

        // handling for CIQ 4.0.0 devices don't support getProperty()
        function getProp(key){
            if (connectIqVer4) {
                var v=null;
                try {
                    v = Application.Properties.getValue(key);
                }
                catch(ex) {
                }
                return v;
            }
            else {
                return getProperty(key);
            }
        }

        function getStringProp(key) {
            var value = getProp(key);
            return value==null ? "" : value;
        }  
  • Do you have a code snippet that we could look at? This could be an issue, as Jim pointed out, that could be related to using Application.Storage vs Application.Properties and it would be helpful to ensure we either have the correct documentation written down, or address any improper behavior within the API. Thanks

  • In general, having a property without settings can be an issue.  I never have a property without settings.  If there is no setting, use Application.Storage instead of Application.Properties,

  • maybe it's worth to include the code you use to read it.