Fix changing of float setting by generic popup
authorH.G. Muller <h.g.muller@hccnet.nl>
Wed, 13 Apr 2011 09:15:14 +0000 (11:15 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Thu, 14 Apr 2011 19:30:18 +0000 (21:30 +0200)
Changing a float setting (so far the only one is in the Load Options
dalog) did not always work, because the old value was clipped to (int),
so that changing it back to an integer value might erroneously conclude
there was no change.

xoptions.c

index 1bccfc3..1d51738 100644 (file)
@@ -1237,13 +1237,14 @@ void GenericReadout()
                    sscanf(val, "%f", &x);
                    if(x > currentOption[i].max) x = currentOption[i].max;
                    if(x < currentOption[i].min) x = currentOption[i].min;
-                   if(currentOption[i].value != x) {
+                   if(currentOption[i].type == Fractional)
+                       *(float*) currentOption[i].target = x; // engines never have float options!
+                   else if(currentOption[i].value != x) {
                        currentOption[i].value = x;
-                       if(currentCps) { // engines never have float options, so no decimals!
+                       if(currentCps) {
                            snprintf(buf, MSG_SIZ,  "option %s=%.0f\n", currentOption[i].name, x);
                            SendToProgram(buf, currentCps);
-                       } else if(currentOption[i].type == Spin) *(int*) currentOption[i].target = x;
-                       else *(float*) currentOption[i].target = x;
+                       } else *(int*) currentOption[i].target = x;
                    }
                    break;
                case CheckBox: