Assertion failed when adding a joint

Hi,

I’m getting this error message when trying to add a joint between a static body image and dynamic body image, respectively known as anchor and block:

Assertion failed: (IsLocked() == false), function CreateJoint, file /Users/ansca/.hudson/jobs/Pong-DMG/workspace/platform/mac/…/…/external/Box2D_v2.1.2/Box2D/Box2D/Dynamics/b2World.cpp, line 184.
/Applications/Corona Game Edition Beta/Corona Terminal: line 9: 1932 Abort trap “$path/Corona Simulator.app/Contents/MacOS/Corona Simulator” $*

Generated by this line:

block.piston = physics.newJoint( “piston”, anchor,block.img , anchor.x,anchor.y , 0,5 )

I have checked thoroughly and anchor, block, block.img, anchor.x and anchor.y are all valid and do, in fact, work as expected slightly lower down in the code.

Is this me or the API?

Thanks,

Matt. [import]uid: 8271 topic_id: 2259 reply_id: 302259[/import]

If anyone (Ansca?) can tell me what lock is involved in the assertion I’d be very grateful - that might give me some clue as to the nature of the locked object, as it is not self-evident from the code, I’m afraid.

Thanks,

Matt. [import]uid: 8271 topic_id: 2259 reply_id: 6833[/import]

Ok, so it looks like it was the way the routine was being called. This may be similar to the bus error post recently put up, but I can’t be sure.

In other parts of my listing I have a table with an image assigned to an index.the image is a body and has a collision listener attached. The function which was throwing the error was getting called by the collision listener.

If I change my code and set a flag to indicate that the image body needs a piston joint attaching and the have a timer which runs round checking the flag, attaching pistons as and when require, the code executes perfectly.

I suspect that the problem is that the image object becomes locked from changes because it has fired a collision event. This would make sense as there would be problems in handling events in objects which have just been, potentially, removed from memory. A similar situation to iterating a table and removing the first, not last, element.

The basic premise, however, of attaching a joint to something which has fired a collision event not being possible is a problem however and I hope that Ansca will agree that this solution is rather inelegant.

Thanks,

Matt. [import]uid: 8271 topic_id: 2259 reply_id: 6839[/import]

I’ve been looking around the issues section of the site and found this:

http://developer.anscamobile.com/issues/1903

Seems to be connected to the issue I was having, but for me adding the joint, not body, in a timer listener seems to have gotten around it.

Does this mean Ansca are looking at this problem?
m [import]uid: 8271 topic_id: 2259 reply_id: 6973[/import]

Just wanted to say thanks for posting this… was having the same problem: adding joints after a collission event.

Fixed by adding the params of the joint to a table and adding them after the completion of the event. [import]uid: 29520 topic_id: 2259 reply_id: 21769[/import]