Details

    • Sub-task
    • Resolution: Invalid
    • P2: Important
    • 4.8.0
    • Qt Script
    • None

    Description

      The use case for setGlobalObject() (http://doc.trolltech.com/4.7/qscriptengine.html#setGlobalObject) is to provide a custom global object. For example, in a browser, the window object acts as the global object. In the QtScript Context2D example (http://doc.trolltech.com/4.7/script-context2d.html), a QObject is used to implement the global object. The API is convenient and powerful since any object can be set as the global object.

      The problem is that the API allows the global object to be replaced at any time, which is not something that JavaScriptCore nor V8 supports; with those APIs, you specify the properties/type of the global object when the script engine is constructed, and can't replace it later.

      The way we solve this currently is by creating a custom "hidden" global object internally, which acts as a proxy in case a custom global object is set. However, this causes issues in various places (performance, and needing hacky checks here and there to make sure we don't compare/return the "hidden" global object).

      The replacement API needs to provide a way to specify the type of the global object at engine construction time; perhaps some type of "template object" which is passed to the constructor.

      Attachments

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

        Activity

          People

            kenthans Kent Hansen (Inactive)
            kenthans Kent Hansen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes