pointers mess up after switching application (solved)

Hi All,

I’m building a program that uses a class that makes nodes. To draw these nodes I sometimes use the location (ofPoint) of their parents. My solution involves giving nodes a pointer to the location of their parent and this seems to work well. However, after I switch application for a bit thinks get buggy, looking at my empty example the pointers (seem to) mess up as the nodes now draw themselves on very different locations from where they are supposed to be.

Does this sound familiar/logical to anyone?



(xcode4, macbook pro)

It’s impossible to see what has gone wrong without looking at the code. One thing that could go wrong is that the parents cease to exist.

The parent nodes still exists. To show the code I need to isolate it from the rest of the program, or it would be quite large. If there is no other option I will, but it is tricky to figure out what to include. I’ll take another stab at it tonight, if I make no progress I’ll start on isolating the code.

For those interested. My problem was caused by the re-allocation of the vector that was holding the elements the pointers were pointing to. This happened because I added elements to the vector (push_back). The problem didn’t show until I switched application, at which point (i assume) the memory previously used by my app got re-used by another.

Now i know.