From 81f5990e0cb6a768ffc5ebb59fe67e6966ffd7de Mon Sep 17 00:00:00 2001 From: Jeena Date: Sun, 1 Mar 2015 16:37:06 +0100 Subject: [PATCH] fixes #96 j.m_collideConnected crash --- app/Game/Core/GameObjects/Doll.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Game/Core/GameObjects/Doll.js b/app/Game/Core/GameObjects/Doll.js index 4bfe6f7..fdc356d 100755 --- a/app/Game/Core/GameObjects/Doll.js +++ b/app/Game/Core/GameObjects/Doll.js @@ -1,5 +1,6 @@ define([ "Game/" + GLOBALS.context + "/GameObjects/GameObject", + "Lib/Utilities/Exception", "Lib/Vendor/Box2D", "Game/Config/Settings", "Game/" + GLOBALS.context + "/Collision/Detector", @@ -7,7 +8,7 @@ define([ "Lib/Utilities/NotificationCenter" ], -function (Parent, Box2D, Settings, CollisionDetector, Item, Nc) { +function (Parent, Exception, Box2D, Settings, CollisionDetector, Item, Nc) { "use strict"; @@ -358,7 +359,14 @@ function (Parent, Box2D, Settings, CollisionDetector, Item, Nc) { }; 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.holdingItem = null;