@edapx wrote:
Hello, I've an error that happens rarely, but when it happens my app crashes.
I've a loop like this:for (auto b:branches) { if(b!= nullptr && b->count > 0){ auto newDir = b->direction / float(b->count); shared_ptr<Branch> nextBranch(new Branch(newDir)); nextBranch->setParent(b); nextBranch->move(newDir * branch_length); branches.push_back(nextBranch); } if(b!= nullptr){ b->reset(); } }
As you see in the loop I'm already checking for a nullptr. But the entry point of my debugger is at the line:
for (auto b:branches) {
One line before my first check for null pointer
How can I avoid this?
The whole app is here https://github.com/edap/testSpaceColonization , and works 99% of the cases.
Posts: 5
Participants: 2