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

Bindings involving JS-owned C++ objects get evaluated at engine destruction with the C++ object-value as null

    XMLWordPrintable

Details

    Description

      This may very well be as-designed, but it seems like a bug, and results in ugly code to avoid lots of binding errors on application exit.

      Attached is an example. It should print something like:

      MyObject(0x1188be8)
      

      when the application starts, and when you close the window that it opens, it will then print.

      null
      

      The property p is assigned a QObject created in CPP, owned by the javascript engine. On engine destruction, that CPP object gets garbage collected, but any bindings involving p get executed with p == null. This leads us to have to check for null in every binding involving these kinds of objects, which is ugly and unexpected:

      property var o: <some C++ object, owned by JS so o should always be valid>
      property int otherProperty: o ? o.value : 0
      

      I'm also trying to track down a crash which looks related, but which I've been unable to generate a small example for.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            jfaust Josh Faust
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes