fixes #96 j.m_collideConnected crash

This commit is contained in:
Jeena 2015-03-01 16:37:06 +01:00
parent 90a282cbd0
commit 81f5990e0c

View file

@ -1,5 +1,6 @@
define([ define([
"Game/" + GLOBALS.context + "/GameObjects/GameObject", "Game/" + GLOBALS.context + "/GameObjects/GameObject",
"Lib/Utilities/Exception",
"Lib/Vendor/Box2D", "Lib/Vendor/Box2D",
"Game/Config/Settings", "Game/Config/Settings",
"Game/" + GLOBALS.context + "/Collision/Detector", "Game/" + GLOBALS.context + "/Collision/Detector",
@ -7,7 +8,7 @@ define([
"Lib/Utilities/NotificationCenter" "Lib/Utilities/NotificationCenter"
], ],
function (Parent, Box2D, Settings, CollisionDetector, Item, Nc) { function (Parent, Exception, Box2D, Settings, CollisionDetector, Item, Nc) {
"use strict"; "use strict";
@ -358,7 +359,14 @@ function (Parent, Box2D, Settings, CollisionDetector, Item, Nc) {
}; };
Doll.prototype.throw = function(item, options) { Doll.prototype.throw = function(item, options) {
this.body.GetWorld().DestroyJoint(this.holdingJoint); if(this.holdingJoint) {
this.body.GetWorld().DestroyJoint(this.holdingJoint);
} else {
// log stack if we called throw without a holdingJoint
var w = new Error("Throwing without a holdingJoint");
console.error(w.message + "\n" + w.stack);
}
this.holdingJoint = null; this.holdingJoint = null;
this.holdingItem = null; this.holdingItem = null;