From b1a4fa5dccd032dba1a209074af4724769a79471 Mon Sep 17 00:00:00 2001 From: brianjjones Date: Tue, 1 Jul 2014 11:07:48 -0700 Subject: [PATCH] Adding some checks to ensure objects aren't undefined before using them Change-Id: Ie00132ae33c8fc2026d451bd4764701b72f83e7e --- js/services/carIndicator.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/js/services/carIndicator.js b/js/services/carIndicator.js index 0aa50ab..1ad83b6 100644 --- a/js/services/carIndicator.js +++ b/js/services/carIndicator.js @@ -466,10 +466,13 @@ CarIndicator.prototype.addListener = function(aCallbackObject) { if (mapping.callBackPropertyName.toLowerCase() === prop.toLowerCase() && !mapping.subscribeCount) { mapping.subscribeCount = typeof (mapping.subscribeCount) === 'undefined' ? 0 : mapping.subscribeCount++; - if (typeof (tizen) !== 'undefined') { + if (typeof (tizen) !== 'undefined' && tizen.vehicle !== undefined && tizen.vehicle[subscribeName] !== undefined) { if (!(subscribeName.toString().trim().toLowerCase() === "nightmode" && id === this._listenerIDs[0])) { - var setUpData = tizen.vehicle[subscribeName].get(zone); - self.onDataUpdate(setUpData, self, id); + if (tizen.vehicle[subscribeName]){ + var setUpData = tizen.vehicle[subscribeName].get(zone); + if (setUpData !== undefined) + self.onDataUpdate(setUpData, self, id); + } } tizen.vehicle[subscribeName].subscribe(subscribeCallback, zone); } else { @@ -493,7 +496,10 @@ CarIndicator.prototype.addListener = function(aCallbackObject) { CarIndicator.prototype.onDataUpdate = function(data, self, lisenersID) { "use strict"; if (data !== undefined) { - var zone = data.zone.toString(2); + if (data.zone !== undefined); + var zone = data.zone.toString(2); + else + var zone = "0"; var mapping; for ( var property in data) { -- 2.7.4