From c4203fe1748bc7e08a5d36830aec4738ee442912 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=BCrg=20Lehni?= <juerg@scratchdisk.com>
Date: Mon, 16 May 2011 19:21:36 +0100
Subject: [PATCH] Change the way associated PathStyles are created and updated.

---
 src/item/Item.js       | 3 ++-
 src/item/PathStyle.js  | 6 +-----
 src/project/Project.js | 4 ++--
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/item/Item.js b/src/item/Item.js
index 7b28fcfd..6dc33785 100644
--- a/src/item/Item.js
+++ b/src/item/Item.js
@@ -19,6 +19,7 @@ var Item = this.Item = Base.extend({
 
 	initialize: function() {
 		paper.project.activeLayer.appendTop(this);
+		this._style = PathStyle.create(this);
 		this.setStyle(this._project.getCurrentStyle());
 	},
 
@@ -629,7 +630,7 @@ var Item = this.Item = Base.extend({
 	},
 
 	setStyle: function(style) {
-		this._style = PathStyle.create(this, style);
+		this._style.initialize(style);
 	},
 
 	// TODO: toString
diff --git a/src/item/PathStyle.js b/src/item/PathStyle.js
index 5e0d0977..6f80d6d7 100644
--- a/src/item/PathStyle.js
+++ b/src/item/PathStyle.js
@@ -44,13 +44,9 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
 		},
 
 		statics: {
-			create: function(item, other) {
+			create: function(item) {
 				var style = new PathStyle(PathStyle.dont);
-				// We need _item to be set before calling initialize(), since
-				// it is setting bean properties that propagate changes through
-				// all of item's children.
 				style._item = item;
-				style.initialize(other);
 				return style;
 			}
 		}
diff --git a/src/project/Project.js b/src/project/Project.js
index 38b90ec3..932d5554 100644
--- a/src/project/Project.js
+++ b/src/project/Project.js
@@ -33,7 +33,7 @@ var Project = this.Project = Base.extend({
 		this.activeView = canvas ? new ProjectView(canvas) : null;
 		this._selectedItems = {};
 		this._selectedItemCount = 0;
-		this.setCurrentStyle(null);
+		this._currentStyle = PathStyle.create(null);
 	},
 
 	getCurrentStyle: function() {
@@ -41,7 +41,7 @@ var Project = this.Project = Base.extend({
 	},
 
 	setCurrentStyle: function(style) {
-		this._currentStyle = PathStyle.create(null, style);
+		this._currentStyle.initialize(style);
 	},
 
 	activate: function() {