From ca76c1d24f8c22f6bb073e590adb42cc737bca06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Wed, 16 Mar 2016 09:56:10 +0100 Subject: [PATCH] Fix #1009: Make sure all name lookup structures are kept in sync for layers too. --- src/item/Item.js | 9 +++++---- src/item/Project.js | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index 4bcf8a70..43d6d54e 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -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); } diff --git a/src/item/Project.js b/src/item/Project.js index d9b74857..b6da5574 100644 --- a/src/item/Project.js +++ b/src/item/Project.js @@ -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);