Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QtScript problem: corrupted Javascirpt variables
Forum Update on Monday, May 27th 2025

QtScript problem: corrupted Javascirpt variables

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 498 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lbalogh
    wrote on 18 Nov 2013, 14:49 last edited by
    #1

    I have tester device which a user can be control by running a Javascript.

    The device is continuously sending measurement data to the program which updates the corresponding variables of the script engine.

    Moreover, in the engine via some custom functions the device is controller.

    Unfortunately, it seems that sometimes (not always) the variables defined in the engine become corrupted.
    For example,
    QScriptValue own_function(QScriptContext *context, QScriptEngine *engine)
    {
    QString Text;

    Text = context->argument(0).toString();
    const QString ret = do_some_processing( Text);
    
    
    return QScriptValue( ret );
    

    }
    implements the function in C++. In Javascript, I have
    for (i=1;i<11;i++)
    {
    x = x+5;
    own_function("value = " + x);
    }

    And sometimes, the variable Text contains invalid string, for example "value = 12[o".

    Some additional info: script engine runs concurently:
    connect(&watcher, SIGNAL(finished()), this, SLOT(onEvalFinished()));
    future = QtConcurrent::run(scriptEngine, &QScriptEngine::evaluate, script_code);
    watcher.setFuture(future);

    In this project Qt 4.8 is used.

    Do you have any idea how it can go wrong?
    Or maybe, is there any rule how I can update a Javascript variable during running of a script engine?
    Thanks.

    Laszlo

    1 Reply Last reply
    0

    1/1

    18 Nov 2013, 14:49

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved