From c0a0c1f4a7a9f3cfd055288817530cf7c46bb26d Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 17 Sep 2013 17:25:42 +0200 Subject: [PATCH] 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 --- history.txt | 2 ++ objects.js | 20 +++++++++++++++++--- store.js | 3 ++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/history.txt b/history.txt index 795e1914..276a187b 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 f0d0e441..9e61d580 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 41e198a5..e51c8dad 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; }; } }