mirror of
https://github.com/qmlnet/qmlnet.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #71] Objects are not surviving re-entry. #43
Labels
No labels
bug
enhancement
help wanted
help wanted
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/qmlnet#43
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pauldotknopf on GitHub (Sep 24, 2018).
Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/71
I checked in a repro in the sandbox project here:
92b9e20726This is the output
Use
QV4_MM_AGGRESSIVE_GC=1to reproduce quicker.@pauldotknopf commented on GitHub (Sep 24, 2018):
It seems as if we made some wrong assumptions about how
JavaScriptOwnershipworks.When QML tracks a
QObjectwithJavaScriptOwnership, it tracks it within the current scope. If that sameQObjectis entered into QML from somewhere else, it doesn't know about the other instance.We made an assumption that QML knows that there is more than one instance of the
QObjectpresent, so only delete theQObjectwhen all scoped usages are done.I'm currently thinking of another approach.
@pauldotknopf commented on GitHub (Sep 24, 2018):
Ok, so this is what I'm thinking.
A 1-N of
NetValueRoot->NetValue.NetValue, aNetValueRootwill be created if not already.NetValuewill be created withJavaScriptOwnership.NetValueinstances will point to the sameNetValueRoot.NetValueis destroyed,NetValueRootwill be deleted as well, releasing the .NET reference for garbage collection.connectNotify/disconnectNotify/metaCallonNetValueto proxy signals/slots to the innerNetValueRoot. This will allow eachNetValueinstance that is alive in QML to seem as if it is the same exactQObjectthat we are interacting with.NetValueRootand activate the signal on it. All theNetValuetypes will be listening to the signals of the innerNetValueRoot.@pauldotknopf commented on GitHub (Sep 24, 2018):
Or, we could leave things as they are, with some slight modifications, and some features removed (that probably won't matter much).
NetValuetypes for all QML scopes.NetValuecreated for each .NET reference id.NetValue::~NetValue()is called, clean up it's reference from the static list of currentNetValueinstances for the given .NET reference id.NetValuethat is present and activate the signal.What do we lose? Any QML attached signal handler won't survive reentry. For example, considering the following sequence:
In this case, the attached signal handler will not get raised. However, the following will work:
In this case, the signal handler will get called, because we are interacting with the same js reference.