From c8d4fbdb647fb8e6c475aeec119d690cd06ccc24 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Fri, 30 Oct 2015 11:06:28 -0400 Subject: [PATCH] Fix when.defer() usage It turns out that there are a bunch of places in our code where we use `when.defer()` and return the deferred instance instead of its `promise` property. This works in most cases because when's deferred promises are thenable, however they don't have all of when's API, like `always`. This change makes sure we correctly return `deferred.promise` everywhere. It's probably a quirk of the version of when we are using that defers aren't always-able and always isn't part of the A+ spec, so there's no reason to add additional tests for these. --- Source/DataSources/KmlDataSource.js | 6 +++--- Source/Scene/GroundPrimitive.js | 2 +- Source/Scene/Model.js | 4 ++-- Source/Scene/Primitive.js | 2 +- Source/Widgets/Viewer/Viewer.js | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/DataSources/KmlDataSource.js b/Source/DataSources/KmlDataSource.js index 4de4d56612bc..651e794471e7 100644 --- a/Source/DataSources/KmlDataSource.js +++ b/Source/DataSources/KmlDataSource.js @@ -203,7 +203,7 @@ define([ deferred.reject(reader.error); }); reader.readAsArrayBuffer(magicBlob); - return deferred; + return deferred.promise; } function readBlobAsText(blob) { @@ -216,7 +216,7 @@ define([ deferred.reject(reader.error); }); reader.readAsText(blob); - return deferred; + return deferred.promise; } function loadXmlFromZip(reader, entry, uriResolver, deferred) { @@ -1644,7 +1644,7 @@ define([ deferred.reject(e); }); - return deferred; + return deferred.promise; } /** diff --git a/Source/Scene/GroundPrimitive.js b/Source/Scene/GroundPrimitive.js index 0e2c825c4f81..e97362abaa94 100644 --- a/Source/Scene/GroundPrimitive.js +++ b/Source/Scene/GroundPrimitive.js @@ -302,7 +302,7 @@ define([ */ readyPromise : { get : function() { - return this._readyPromise; + return this._readyPromise.promise; } } }); diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js index fc59f40598d0..70cd6ec80f70 100644 --- a/Source/Scene/Model.js +++ b/Source/Scene/Model.js @@ -686,7 +686,7 @@ define([ */ readyPromise : { get : function() { - return this._readyPromise; + return this._readyPromise.promise; } }, @@ -3103,7 +3103,7 @@ define([ var model = this; frameState.afterRender.push(function() { model._ready = true; - model.readyPromise.resolve(model); + model._readyPromise.resolve(model); }); return; } diff --git a/Source/Scene/Primitive.js b/Source/Scene/Primitive.js index 5d9b6f8152ea..ceef4df0db16 100644 --- a/Source/Scene/Primitive.js +++ b/Source/Scene/Primitive.js @@ -433,7 +433,7 @@ define([ */ readyPromise : { get : function() { - return this._readyPromise; + return this._readyPromise.promise; } } }); diff --git a/Source/Widgets/Viewer/Viewer.js b/Source/Widgets/Viewer/Viewer.js index 9537d5f8d51d..74001f284302 100644 --- a/Source/Widgets/Viewer/Viewer.js +++ b/Source/Widgets/Viewer/Viewer.js @@ -1557,7 +1557,7 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to } }); - return zoomPromise; + return zoomPromise.promise; } function clearZoom(viewer) {