summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-09-18 17:06:08 +0200
committerjmoenig <jens@moenig.org>2013-09-18 17:06:08 +0200
commitdaff84a97a7b0936f6008b8458dec22ba42b151b (patch)
treefd35349ae85b88edd52022f401abf31201e88115
parente9afcc9ec3e990eb1ebc79790fcf5048372858c1 (diff)
downloadsnap-daff84a97a7b0936f6008b8458dec22ba42b151b.tar.gz
snap-daff84a97a7b0936f6008b8458dec22ba42b151b.zip
Prevent local custom blocks in global custom block definitions
fixes #167 for future projects
-rw-r--r--byob.js32
-rwxr-xr-xhistory.txt1
2 files changed, 30 insertions, 3 deletions
diff --git a/byob.js b/byob.js
index 8954c6a..004ef87 100644
--- a/byob.js
+++ b/byob.js
@@ -105,7 +105,7 @@ CommentMorph, localize, CSlotMorph, SpeechBubbleMorph, MorphicPreferences*/
// Global stuff ////////////////////////////////////////////////////////
-modules.byob = '2013-July-04';
+modules.byob = '2013-September-18';
// Declarations
@@ -1602,10 +1602,35 @@ BlockEditorMorph.prototype.cancel = function () {
};
BlockEditorMorph.prototype.close = function () {
- // allow me to disappear only when name collisions
- // have been resolved
var doubles, block,
myself = this;
+
+ // assert that no scope conflicts exists, i.e. that a global
+ // definition doesn't contain any local custom blocks, as they
+ // will be rendered "Obsolete!" when reloading the project
+ if (this.definition.isGlobal) {
+ block = detect(
+ this.body.contents.allChildren(),
+ function (morph) {
+ return morph.definition && !morph.definition.isGlobal;
+ }
+ );
+ if (block) {
+ block = block.definition.blockInstance();
+ block.addShadow();
+ new DialogBoxMorph().inform(
+ 'Local Block(s) in Global Definition',
+ 'This global block definition contains one or more\n'
+ + 'local custom blocks which must be removed first.',
+ myself.world(),
+ block.fullImage()
+ );
+ return;
+ }
+ }
+
+ // allow me to disappear only when name collisions
+ // have been resolved
doubles = this.target.doubleDefinitionsFor(this.definition);
if (doubles.length > 0) {
block = doubles[0].blockInstance();
@@ -1619,6 +1644,7 @@ BlockEditorMorph.prototype.close = function () {
);
return;
}
+
this.destroy();
};
diff --git a/history.txt b/history.txt
index 625bb1d..ca18e11 100755
--- a/history.txt
+++ b/history.txt
@@ -1916,3 +1916,4 @@ ______
130918
------
* Objects, GUI: prevent costumes with CORS-tainted canvases, expected to fix #155, #154, #151, #148, #147, #127 for future projects
+* BYOB: Prevent local custom blocks in global custom block definitions, fixes #167 for future projects