Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Does QJSValue protect its value from garbage collection?
Forum Updated to NodeBB v4.3 + New Features

Does QJSValue protect its value from garbage collection?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 388 Views 1 Watching
  • 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.
  • P Offline
    P Offline
    pderocco
    wrote on last edited by
    #1

    This question came up in the context of another post, so I thought I'd ask it directly, since someone who might know the answer might not have read the other post.

    I'm wondering if a QJSValue that records a JavaScript object in C++ ensures that that object is reachable to the JS memory manager, and won't be garbage collected. I've looked at the source for QJSValue objects, and don't see any mechanism that would would let the collector mark these objects.

    But in that other post, I did a test:

    https://forum.qt.io/topic/106534/pass-opaque-javascript-type-to-and-from-c/9

    and in that simple case, the object seemed to be preserved. However, I don't know if it really was preserved, or if it was accessing the ghost of the object that simply hadn't been scribbled over yet.

    So can anyone provide a definitive answer to this?

    1 Reply Last reply
    0

    • Login

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