opensourceBIM / BIMserver-JavaScript-API

BIMserver JavaScript API
GNU Lesser General Public License v3.0
55 stars 35 forks source link

Fix: this.loadedTypes[object._t] undefined #31

Closed GiacomoManzoli closed 5 years ago

GiacomoManzoli commented 5 years ago

The PR #15 introduces an error sincethis.loadedTypes[object._t] can be undefined in certain cases. This is because this.loadedTypes[object._t] is initialized only if the object this.objects[object._i] doesn't exists.

This PR moves the check

if (!this.loadedTypes[object._t]) { 
    this.loadedTypes[object._t] = {} 
}

outside the main if, so it's always checked.

GiacomoManzoli commented 5 years ago

I've also prepared some demo code to test the fix. The code it's available on os8bim/DemoFix and includes the proposed fix.