hi
if i shot at my scenenode with a gun , the nodes lost health points...
at healthpoints ==0 i try to remove them but if i
node->remove()
i get sometimes a crash at ->drawAll()
but if i do a
node->setVisible(false);
i get no crash , but this is a stupid solution.....
have anybody else this problem ....
bug at remove() ?
....
me i think i have fixed the bug now, but i don't know the reason why there was a bug
let me explain.
[thread 1 ]
remove() a scenenode
and
drawAll()
[thread2]
remove() another sceennode
-----
if thread1 removes the node i catch an execption at drawall
but if i set up a mutex on the 2 removes() and the one drawall()
there is no bug at all... but why not ??
is it possible that the 2 threads run through remove() at the same time ??
best regards
let me explain.
[thread 1 ]
remove() a scenenode
and
drawAll()
[thread2]
remove() another sceennode
-----
if thread1 removes the node i catch an execption at drawall
but if i set up a mutex on the 2 removes() and the one drawall()
there is no bug at all... but why not ??
is it possible that the 2 threads run through remove() at the same time ??
best regards
Sort of, acutally, it is quite possible for threads to step on each other. The OS level of threading is very complex, but basically, one thread may start a remove, and then the OS gives another thread some time and it then also does a remove. If it was impossible for threads to step on each other, there would be no need for mutexes.killer7 wrote:thats impossable, threads mearly sub-devide time, only one thread is actully running at a time.
They just switch back and forth between threads so quickly you cant see the difference .
Anyways, that was definitely your problem. If you have multiple threads which do anything to the same data then you need to have a mutex to protect that data.