Prevent local custom blocks in global custom block definitions

fixes #167 for future projects
pull/3/merge
jmoenig 2013-09-18 17:06:08 +02:00
rodzic e9afcc9ec3
commit daff84a97a
2 zmienionych plików z 30 dodań i 3 usunięć

32
byob.js
Wyświetl plik

@ -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();
};

Wyświetl plik

@ -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