summaryrefslogtreecommitdiff
path: root/fluid/Shortcut_Button.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2022-11-24 12:35:20 +0100
committerMatthias Melcher <github@matthiasm.com>2022-11-24 12:35:32 +0100
commit8978bd1a842124e7c151c3fcdffec5bce103f808 (patch)
treeec7ec87f63564de126ff8ea78349b9507868d412 /fluid/Shortcut_Button.cxx
parent314f464cd526d2060cba420ce2060605a393b70e (diff)
FLUID: Fix update of formula input widgets
Diffstat (limited to 'fluid/Shortcut_Button.cxx')
-rw-r--r--fluid/Shortcut_Button.cxx17
1 files changed, 12 insertions, 5 deletions
diff --git a/fluid/Shortcut_Button.cxx b/fluid/Shortcut_Button.cxx
index 9c64b760a..97fa7f262 100644
--- a/fluid/Shortcut_Button.cxx
+++ b/fluid/Shortcut_Button.cxx
@@ -203,7 +203,8 @@ void Fluid_Coord_Input::callback_handler_cb(Fluid_Coord_Input *This, void *v) {
void Fluid_Coord_Input::callback_handler(void *v) {
if (user_callback_)
(*user_callback_)(this, v);
- value( value() );
+ // do *not* update the value to show the evaluated fomule here, because the
+ // values of the variables have already updated after the user callback.
}
/**
@@ -238,14 +239,20 @@ int Fluid_Coord_Input::eval_var(uchar *&s) const {
\return the value so far
*/
int Fluid_Coord_Input::eval(uchar *&s, int prio) const {
- int v =0, sgn = 1;
+ int v = 0, sgn = 1;
uchar c = *s++;
+ // check for end of text
+ if (c==0) { s--; return sgn*v; }
+
// check for unary operator
if (c=='-') { sgn = -1; c = *s++; }
else if (c=='+') { sgn = 1; c = *s++; }
- if (c>='0' && c<='9') {
+ // read value, variable, or bracketed term
+ if (c==0) {
+ s--; return sgn*v;
+ } else if (c>='0' && c<='9') {
// numeric value
while (c>='0' && c<='9') {
v = v*10 + (c-'0');
@@ -265,6 +272,7 @@ int Fluid_Coord_Input::eval(uchar *&s, int prio) const {
// Now evaluate all following binary operators
for (;;) {
if (c==0) {
+ s--;
return v;
} else if (c=='+' || c=='-') {
if (prio<=4) { s--; return v; }
@@ -283,8 +291,7 @@ int Fluid_Coord_Input::eval(uchar *&s, int prio) const {
} else {
return v; // syntax error
}
- c = *s;
- if (c) s++;
+ c = *s++;
}
return v;
}