repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 0e9c48810e0a6b5010b54f4c38664e474911434b:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 0e9c48810e0a6b5010b54f4c38664e474911434b
Author: James Baicoianu 
Date:   Thu Feb 22 13:47:54 2018 +0000

    Better handling of undefined functions during init

diff --git a/scripts/janusbase.js b/scripts/janusbase.js
index 894809a458b774d1715b868ec3b06c3c82bfdb2b..
index ..841eefd530e3fed594df9818fff36a8e776b0173 100644
--- a/scripts/janusbase.js
+++ b/scripts/janusbase.js
@@ -62,11 +62,13 @@ elation.require(['engine.things.generic', 'utils.template'], function() {

       // FIXME - saving references to bound functions, for future use.  This should happen deeper in the component framework
       this.handleFrameUpdates = elation.bind(this, this.handleFrameUpdates);
+      this.created = false;
     }
     this.createChildren = function() {
       if (typeof this.create == 'function') {
         this.create();
       }
+      this.created = true;
     }
     this.updateColor = function() {
       if (this.properties.color === this.defaultcolor) {
@@ -427,7 +429,7 @@ elation.require(['engine.things.generic', 'utils.template'], function() {
       this.resetFrameUpdates();
       this.dispatchEvent({type: 'update', data: ev.data});
       var proxy = this.getProxyObject();
-      if (typeof proxy.update == 'function') {
+      if (typeof proxy.update == 'function' && this.created) {
         proxy.update(ev.data);
       }
     }
@@ -516,7 +518,7 @@ elation.require(['engine.things.generic', 'utils.template'], function() {
         proxyobj = this.room.jsobjects[obj];
       }
       if (proxyobj) {
-        if (proxyobj.parent) {
+        if (proxyobj.parent && typeof proxyobj.parent.removeChild == 'function') {
           proxyobj.parent.removeChild(proxyobj);
         }
         //var realobj = this.room.getObjectFromProxy(proxyobj);
@@ -524,7 +526,9 @@ elation.require(['engine.things.generic', 'utils.template'], function() {
         if (realobj) {
           this.add(realobj);
           this.updateScriptChildren();
-          realobj.start();
+          if (typeof realobj.start == 'function') {
+            realobj.start();
+          }
         }
       }
     }

-----END OF PAGE-----