summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-09-17 17:25:42 +0200
committerjmoenig <jens@moenig.org>2013-09-17 17:25:42 +0200
commitc0a0c1f4a7a9f3cfd055288817530cf7c46bb26d (patch)
tree785cf1d7c7b51cce6453c7fec14d5742bf51b2b2
parent0947fbb80e6d4c57c63c588354e101a35bec087a (diff)
downloadsnap-yow-c0a0c1f4a7a9f3cfd055288817530cf7c46bb26d.tar.gz
snap-yow-c0a0c1f4a7a9f3cfd055288817530cf7c46bb26d.zip
fixed part of #154 - prevent costumes from being drawn while they are loading
prevents an occasional DOM error saying "an attempt was made to use an object that is not, or is no longer, usable" when loading a project that has costumes
-rwxr-xr-xhistory.txt2
-rw-r--r--objects.js20
-rw-r--r--store.js3
3 files changed, 21 insertions, 4 deletions
diff --git a/history.txt b/history.txt
index 795e191..276a187 100755
--- a/history.txt
+++ b/history.txt
@@ -1910,3 +1910,5 @@ ______
------
* Cloud: encodeDict() fix and new parseDict() method - used for accessing shared projects
* GUI: fixed #119, #149 (accessing a shared projects requires lowercasing the username)
+* Portuguese translation update for SPLIT block, thanks, Manuel!
+* Store, Objects: prevent costumes from being drawn while they are loading, fixes parts of #154
diff --git a/objects.js b/objects.js
index f0d0e44..9e61d58 100644
--- a/objects.js
+++ b/objects.js
@@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.objects = '2013-September-16';
+modules.objects = '2013-September-17';
var SpriteMorph;
var StageMorph;
@@ -1248,6 +1248,8 @@ SpriteMorph.prototype.drawNew = function () {
currentCenter = this.center(),
facing, // actual costume heading based on my rotation style
isFlipped,
+ isLoadingCostume = this.costume &&
+ typeof this.costume.loaded === 'function',
pic, // (flipped copy of) actual costume based on my rotation style
stageScale = this.parent instanceof StageMorph ?
this.parent.scale : 1,
@@ -1257,7 +1259,8 @@ SpriteMorph.prototype.drawNew = function () {
shift,
corner,
costumeExtent,
- ctx;
+ ctx,
+ handle;
if (this.isWarped) {
this.wantsRedraw = true;
@@ -1271,7 +1274,7 @@ SpriteMorph.prototype.drawNew = function () {
isFlipped = true;
}
}
- if (this.costume) {
+ if (this.costume && !isLoadingCostume) {
pic = isFlipped ? this.costume.flipped() : this.costume;
// determine the rotated costume's bounding box
@@ -1328,6 +1331,17 @@ SpriteMorph.prototype.drawNew = function () {
this.setCenter(currentCenter, true); // just me
SpriteMorph.uber.drawNew.call(this, facing);
this.rotationOffset = this.extent().divideBy(2);
+ if (isLoadingCostume) { // retry until costume is done loading
+ handle = setInterval(
+ function () {
+ myself.changed();
+ myself.drawNew();
+ myself.changed();
+ clearInterval(handle);
+ },
+ 100
+ );
+ }
}
this.version = Date.now();
};
diff --git a/store.js b/store.js
index 41e198a..e51c8da 100644
--- a/store.js
+++ b/store.js
@@ -61,7 +61,7 @@ SyntaxElementMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.store = '2013-August-10';
+modules.store = '2013-September-17';
// XML_Serializer ///////////////////////////////////////////////////////
@@ -673,6 +673,7 @@ SnapSerializer.prototype.loadCostumes = function (object, model) {
} else {
costume.loaded = function () {
object.wearCostume(costume);
+ this.loaded = true;
};
}
}