Uploaded image for project: 'Qbs ("Cubes")'
  1. Qbs ("Cubes")
  2. QBS-1269

Module property undefined in external Javascript file function

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Invalid
    • Affects Version/s: 1.10.0
    • Fix Version/s: None
    • Labels:
      None

      Description

      I'm trying to organize some logic into a javascript file, and then re-use it in a module. However, my custom module properties are undefined in the file function, but ok locally.  The "qbs" module property is fine in either case, which I can understand because its definition is complete from my module's perspective. Is there a problem when crossing interpreter boundaries? Should this be supported, or am I pushing my luck?

      // mModule.qbs
      import qbs
      import qbs.Environment
      import "my.js" as myjs
      
      Module {
        name: "myModule"
        property string first:  "foo"
        property string second: myjs.getFirst( this ) // returns undefined
        property string third:  myjs.getQbs( qbs )
        property string fourth: { return first; }
        property string fifth:  { return qbs.targetOS.contains("bsd")?"Y":"N"; }
        property string sixth:  {
            console.log( "second="  + second +
                         " third="  + third +
                         " fourth=" + fourth +
                         " fifth="  + fifth );
            return "bar";
        }
      }
      
      // my.js
      function getFirst(module)
      {
              console.log( "js first=" + module.first );
              return module.first;
      }
      function getQbs(qbs)
      {
              console.log( "targetOS=" + qbs.targetOS );
              return qbs.targetOS.contains("bsd") ? "yes" : "no";
      }
      
      // Console output:
      DEBUG: js first=undefined
      DEBUG: targetOS=macos,darwin,bsd,unix
      DEBUG: second=undefined third=yes fourth=foo fifth=Y
      

        Attachments

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

          Activity

            People

            Assignee:
            jakepetroules Jake Petroules (DO NOT ASSIGN ISSUES)
            Reporter:
            remik Remik Ziemlinski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes