← Back to team overview

kicad-developers team mailing list archive

Re: A fix for our TEXT_CTRL_EVAL class.

 

Hi JP,

Rather than calling evaluate() in the new TEXT_CTRL_EVAL::SetValue(), I’d call clear(), and add these two lines to NumericEvaluator::clear():

  void
  NumericEvaluator :: clear()
  {
     free(clToken.token);
     clToken.token = nullptr;
     clToken.input = nullptr;
     bClError = true;
+
+    if (bClTextInputStorage)
+       clObjMap[pObj] = nullptr;
  }

That will zero out the stored text.

Cheers,
Jeff.



> On 25 Feb 2018, at 10:17, jp charras <jp.charras@xxxxxxxxxx> wrote:
> 
> Hi Orson,
> 
> Could you have a look into this small patch.
> I am not sure I used the better way to fix an issue.
> 
> It fixes an issue when using SetValue() to change the value shown by this widget.
> 
> The issue was due to the fact TEXT_CTRL_EVAL stores internally the last entered value in a buffer.
> So when calling SetValue() after a value was already entered, and if we try to modify
> the displayed value by calling SetValue(), as soon as the widget has the focus, the previous value
> replaces the new value.
> 
> This is easy to see in Move Exactly dialog:
> - enter a value
> - reset the value by the Reset button
> - move the cursor to the corresponding text control widgets and click on it to give it the focus.
> 
> -- 
> Jean-Pierre CHARRAS
> <fix_text_ctrl_eval_SetValue.patch>_______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp


Follow ups

References