Does QJSValue protect its value from garbage collection?



  • 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?


Log in to reply