diff options
author | randomguy3 <randomguy3@7c02a99a-9b00-45e3-bf44-6f3dd7fddb64> | 2012-03-08 18:22:22 +0000 |
---|---|---|
committer | randomguy3 <randomguy3@7c02a99a-9b00-45e3-bf44-6f3dd7fddb64> | 2012-03-08 18:22:22 +0000 |
commit | 0cd05a572e48b1e649ecdc8b24920c497e40466e (patch) | |
tree | 3f6e2aa5543c809fc7727e070c5e7ae11f3eaa3e /tikzit/src/common/Node.m | |
parent | d26e56e2fd57da2dadddf760b2984956f7daa069 (diff) |
Fix how copying is implemented
git-svn-id: https://tikzit.svn.sourceforge.net/svnroot/tikzit/trunk@419 7c02a99a-9b00-45e3-bf44-6f3dd7fddb64
Diffstat (limited to 'tikzit/src/common/Node.m')
-rw-r--r-- | tikzit/src/common/Node.m | 64 |
1 files changed, 12 insertions, 52 deletions
diff --git a/tikzit/src/common/Node.m b/tikzit/src/common/Node.m index 136fe20..39b1e75 100644 --- a/tikzit/src/common/Node.m +++ b/tikzit/src/common/Node.m @@ -34,7 +34,6 @@ style = nil; label = @""; point = p; - //[self updateData]; return self; } @@ -122,12 +121,6 @@ [self setLabel:[nd label]]; } -- (id)copy { - Node *cp = [[Node alloc] init]; - [cp setPropertiesFromNode:self]; - return cp; -} - + (Node*)nodeWithPoint:(NSPoint)p { return [[[Node alloc] initWithPoint:p] autorelease]; } @@ -149,56 +142,21 @@ } } - -- (NSString*)name { - return name; -} - -- (void)setName:(NSString *)s { - if (name != s) { - [name release]; - name = [s copy]; - } -} - -- (NSString*)label { - return label; -} - -- (void)setLabel:(NSString *)s { - if (label != s) { - [label release]; - label = [s copy]; - } -} - -- (GraphElementData*)data { - return data; -} - -- (void)setData:(GraphElementData*)dt { - if (data != dt) { - [data release]; - data = [dt copy]; - } -} - -- (NSPoint)point { - return point; -} - -- (void)setPoint:(NSPoint)value { - point = value; -} +@synthesize name; +@synthesize label; +@synthesize point; +@synthesize data; - (NodeStyle*)style { return style; } - (void)setStyle:(NodeStyle *)st { - NodeStyle *oldStyle = style; - style = [st retain]; - [oldStyle release]; + if (style != st) { + NodeStyle *oldStyle = style; + style = [st retain]; + [oldStyle release]; + } [self updateData]; } @@ -210,7 +168,9 @@ } - (id)copyWithZone:(NSZone*)z { - return nil; + Node *cp = [[Node allocWithZone:z] init]; + [cp setPropertiesFromNode:self]; + return cp; } @end |