Fix #1009: Make sure all name lookup structures are kept in sync for layers too.

This commit is contained in:
Jürg Lehni 2016-03-16 09:56:10 +01:00
parent d52a6f3107
commit ca76c1d24f
2 changed files with 10 additions and 4 deletions

View file

@ -2352,13 +2352,14 @@ new function() { // Injection scope for hit-test functions shared with project
// See #_remove() for an explanation of this:
notifySelf = project && project._changes;
for (var i = 0, l = items.length; i < l; i++) {
var item = items[i];
var item = items[i],
name = item._name;
item._parent = this;
item._setProject(this._project, true);
// Setting the name again makes sure all name lookup structures
// Set the name again to make sure all name lookup structures
// are kept in sync.
if (item._name)
item.setName(item._name);
if (name)
item.setName(name);
if (notifySelf)
this._changed(/*#=*/Change.INSERTION);
}

View file

@ -355,6 +355,11 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
layer._remove(false, true);
Base.splice(this._children, [layer], index, 0);
layer._setProject(this, true);
// Set the name again to make sure all name lookup structures
// are kept in sync.
var name = layer._name;
if (name)
layer.setName(name);
// See Item#_remove() for an explanation of this:
if (this._changes)
layer._changed(/*#=*/Change.INSERTION);