bug at remove() ?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
ig0r

bug at remove() ?

Post by ig0r »

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 ....
Morrog
Posts: 58
Joined: Mon Dec 13, 2004 5:13 am

Post by Morrog »

I've removed gobs of node without a problem. I think you have a bug elsewhere.
ig0r

---

Post by ig0r »

i cannnot belive, because everything works fine if i set them invisible, but if i do a remove() i get a crash at 0xfeefeeee in drawALL()

is it not possible to remove more nodes at once ???
ig0r

....

Post by ig0r »

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
killer7
Posts: 14
Joined: Fri Dec 10, 2004 2:42 am
Location: Chicago, USA

Post by killer7 »

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 .
Know modeling?

Got spare time?

Email me: moe@cgispy.com
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post by bal »

sgmr->addToDeletionQueue(node);

?
General Tools List
General FAQ
System: AMD Barton 2600+, 512MB, 9600XT 256MB, WinXP + FC3
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

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 .
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.

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.
Post Reply