Skip to content

Commit

Permalink
Fix #3
Browse files Browse the repository at this point in the history
  • Loading branch information
towerofnix committed Dec 11, 2016
1 parent 1116f58 commit 0577cf6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
19 changes: 11 additions & 8 deletions src/blocks/Block.as
Original file line number Diff line number Diff line change
Expand Up @@ -887,14 +887,7 @@ public class Block extends Sprite {
// TODO: Remove any waiting reporter data in the Scratch.app.extensionManager
if (parent is Block) Block(parent).removeBlock(this);
else if (parent) parent.removeChild(this);

// Remove from the Scratch object that holds the block, if it's in the
// object's script array
var obj:ScratchObj = app.viewedObj();
var index:int = obj.scripts.indexOf(this);
if (index >= 0) {
obj.scripts.splice(index, 1);
}
removeFromParentObjScriptList();

this.cacheAsBitmap = false;
// set position for undelete
Expand All @@ -908,6 +901,16 @@ public class Block extends Sprite {
return true;
}

public function removeFromParentObjScriptList():void {
// Remove from the Scratch object that holds the block, if it's in the
// object's script array
var obj:ScratchObj = Scratch.app.viewedObj();
var index:int = obj.scripts.indexOf(this);
if (index >= 0) {
obj.scripts.splice(index, 1);
}
}

public function attachedCommentsIn(scriptsPane:ScriptsPane):Array {
var allBlocks:Array = [];
allBlocksDo(function (b:Block):void {
Expand Down
3 changes: 2 additions & 1 deletion src/uiwidgets/ScriptsPane.as
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ public class ScriptsPane extends ScrollFrameContents {
} else {
if(app.editMode) b.hideRunFeedback();
b.cacheAsBitmap = false;
b.removeFromParentObjScriptList();
if (b.isReporter) {
Block(nearestTarget[1].parent).replaceArgWithBlock(nearestTarget[1], b, this);
} else {
Expand All @@ -277,7 +278,7 @@ public class ScriptsPane extends ScrollFrameContents {
}
}
}
if (b.op == Specs.PROCEDURE_DEF) app.updatePalette();
app.updatePalette();
app.runtime.blockDropped(b);
}

Expand Down

0 comments on commit 0577cf6

Please sign in to comment.