Hello anda_skoa,
I was afraid m_pName = 0; would make it look like I'm explicitly changing the pointer and not notifying about it. This is not what is happening. I just wrote that to make double deletions in this contrived example not crash.
You can remove m_pName = 0; part. The code will still behave the same. What is implied here is that m_pName is not being changed. delete m_pName will do nothing to m_pName (nothing happens to the pointer, only the pointee will be destructed). Still delete m_pName is detected by QML in certain scenarios and not in other. I suspect from experimenting that this detection has nothing to do with the way user codes. If QObject* from c++ is bound to some property QtObject someName in QML then there is a silent connection being made with the c++ QObject's destroyed signal. That way whenever the QObject is destroyed in c++ through any mechanism the corresponding someName also becomes null (though no one explicitly made anything null - pointers are still pointing to the same location in the memory although a destroyed/reclaimed one).
Are all these assumptions right?
Here is something simpler to support my assumption:
before and after the call to objRoot.deleteName() in MouseArea's click handler in the code give try to consol.log(objRect.temp, objRoot.name). You will get valid memory address before the call and null after the call for both of them.
How does this happen? No one has explicity changed the content of the pointer in c++?
It would be a great help if you can help me figure this out as it is a major conceptual mystery right now in my project.
Bookmarks