changeset 755:f574028932cc

Fix for crash when changing background colors, needed retain and release.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 17 Mar 2011 14:58:59 +0000
parents 0d0dc78c589d
children ef17c8079f1d
files mac/dw.m
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Thu Mar 17 06:13:57 2011 +0000
+++ b/mac/dw.m	Thu Mar 17 14:58:59 2011 +0000
@@ -496,7 +496,7 @@
     if(bgcolor)
     {
         [bgcolor set];
-        NSRectFill( [self bounds] );
+        NSRectFill([self bounds]);
     }
 }
 -(BOOL)isFlipped { return YES; }
@@ -509,14 +509,17 @@
 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); _event_handler([self window], theEvent, 2); }
 -(void)setColor:(unsigned long)input
 {
+    id orig = bgcolor;
+    
     if(input == _colors[DW_CLR_DEFAULT])
     {
         bgcolor = nil;
     }
     else
     {
-        bgcolor = [NSColor colorWithDeviceRed: DW_RED_VALUE(input)/255.0 green: DW_GREEN_VALUE(input)/255.0 blue: DW_BLUE_VALUE(input)/255.0 alpha: 1];
-    }
+        bgcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(input)/255.0 green: DW_GREEN_VALUE(input)/255.0 blue: DW_BLUE_VALUE(input)/255.0 alpha: 1] retain];
+    }
+    [orig release];
 }
 @end