Search code examples
c++qlist

QList, appending object, loosing static members


I'm using building a QList in my object:

QList<clsXMLnode*> mlstChildren;

In my method to append a child node:

void clsXMLnode::appendChild(clsXMLnode* pobjChild) {
assert(pobjChild != NULL);
mlstChildren.append(pobjChild);
// ...

When I use the debugger to single step I can see that pobjChild has all the static data that it should have associated with it, however the node that is appended to 'mlstChildren' has none of the static members. Using the debugger I can see the 'pobjChild' is still correct and 'mlstChildren' whilst it has the same pointer address for the child node, the contents of it do not match the contents of 'pobjChild', why?

Edit:
It seems to be a bug in the debugger, I modified my appendChild method as follows:

void clsXMLnode::appendChild(clsXMLnode* pobjChild) {
assert(pobjChild != NULL);
int intNewIdx = mlstChildren.length();
mlstChildren.append(pobjChild);
clsXMLnode* pobjCheck = mlstChildren.at(intNewIdx);
// ...

I can see in the debugger that the contents of pobjCheck matches the contents of pobjChild exactly and all static members are intact, but if I expand mlstChildren in the debugger, whilst the class address matches pobjChild, the contents of the static data does not.


Solution

  • This isn't really an answer, however I think I've proven that it is one of several ongoing bugs in the Qt Debugger, which I have reported to the Qt developers forum:

    https://forum.qt.io/topic/82279/debugger-and-static-data