diff options
| author | jmoenig <jens@moenig.org> | 2013-09-18 17:06:08 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-09-18 17:06:08 +0200 |
| commit | daff84a97a7b0936f6008b8458dec22ba42b151b (patch) | |
| tree | fd35349ae85b88edd52022f401abf31201e88115 /byob.js | |
| parent | e9afcc9ec3e990eb1ebc79790fcf5048372858c1 (diff) | |
| download | snap-byow-daff84a97a7b0936f6008b8458dec22ba42b151b.tar.gz snap-byow-daff84a97a7b0936f6008b8458dec22ba42b151b.zip | |
Prevent local custom blocks in global custom block definitions
fixes #167 for future projects
Diffstat (limited to 'byob.js')
| -rw-r--r-- | byob.js | 32 |
1 files changed, 29 insertions, 3 deletions
@@ -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(); }; |
