Fix #991: Make sure items get fully removed in removeChildren()

This commit is contained in:
Jürg Lehni 2016-02-23 11:59:59 +01:00
parent 1cb291690d
commit 9f90659fdb
4 changed files with 19 additions and 10 deletions

View file

@ -41,7 +41,7 @@
var connections = new Group();
function generateConnections(paths) {
// Remove the last connection paths:
connections.children = [];
connections.removeChildren();
for (var i = 0, l = paths.length; i < l; i++) {
for (var j = i - 1; j >= 0; j--) {

View file

@ -31,7 +31,7 @@
}
function renderDiagram() {
project.activeLayer.children = [];
project.activeLayer.removeChildren();
var diagram = voronoi.compute(sites, bbox);
if (diagram) {
for (var i = 0, l = sites.length; i < l; i++) {

View file

@ -2528,14 +2528,21 @@ new function() { // Injection scope for hit-test functions shared with project
var owner = this._getOwner(),
project = this._project,
index = this._index;
if (owner && index != null) {
// Only required for layers, but not enough to merit an override.
if (project._activeLayer === this)
project._activeLayer = this.getNextSibling()
|| this.getPreviousSibling();
if (owner) {
// Handle index separately from owner: There are situations where
// the item is already removed from its list through Base.splice()
// and index set to undefined, but the owner is still set,
// e.g. in #removeChildren():
if (index != null) {
// Only required for layers but not enough to merit an override.
if (project._activeLayer === this)
project._activeLayer = this.getNextSibling()
|| this.getPreviousSibling();
Base.splice(owner._children, null, index, 1);
}
// Handle named children separately from index:
if (this._name)
this._removeNamed();
Base.splice(owner._children, null, index, 1);
this._installEvents(false);
// Notify self of the insertion change. We only need this
// notification if we're tracking changes for now.

View file

@ -855,8 +855,9 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
// should not set this.
updateMatrix: true
});
for (var i = 0, l = children.length; i < l; i++)
for (var i = 0, l = children.length; i < l; i++) {
children[i].draw(ctx, param);
}
ctx.restore();
// Draw the selection of the selected items in the project:
@ -866,8 +867,9 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
var items = this._selectedItems,
size = this._scope.settings.handleSize,
version = this._updateVersion;
for (var id in items)
for (var id in items) {
items[id]._drawSelection(ctx, matrix, size, items, version);
}
ctx.restore();
}
}