Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-39416

callee is wrong for nested property getters

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P3: Somewhat important
    • None
    • 5.2.0, 5.2.1, 5.3.0
    • Qt Script
    • None
    • Windows 7 x86_64, MSVC 2013, Qt 5.3.0

    Description

      Consider the following code

      QScriptValue js_func2(QScriptContext *ctx, QScriptEngine *engine)
      {
          qDebug() << "func2 callee is" << ctx->callee().objectId() << ctx->callee().toString();
          return QScriptValue("result of func2");
      }
      
      QScriptValue js_func1(QScriptContext *ctx, QScriptEngine *engine)
      {
          QScriptValue func2 = engine->newFunction(js_func2);
          qDebug() << "func2 callee should be" << func2.objectId() << ctx->callee().toString();
          QScriptValue obj = engine->newObject();
          obj.setProperty("func2", func2, QScriptValue::PropertyGetter);
          obj.setProperty("name", "Egon");
          return obj;
      }
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
          QScriptEngine engine;
      
          QScriptValue func1 = engine.newFunction(js_func1);
          engine.globalObject().setProperty("func1", func1, QScriptValue::PropertyGetter);
          qDebug() << engine.evaluate("JSON.stringify(func1)").toString();
          return 0;
      }
      

      The callee of func2 should be its function object. But the callee is the JSON.stringify function object.

      The output of the above program is

      func2 callee should be 729437188224 "function () {
          [native code]
      }"
      func2 callee is 729437188096 "function stringify() {
          [native code]
      }"
      "{"func2":"result of func2","name":"Egon"}"
      

      Note that this issue does occur on Windows only.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            laknoll Lars Knoll
            jbornema Joerg Bornemann
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes