comparison mac/dw.m @ 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 2fb17622a455
comparison
equal deleted inserted replaced
754:0d0dc78c589d 755:f574028932cc
494 -(void)drawRect:(NSRect)rect 494 -(void)drawRect:(NSRect)rect
495 { 495 {
496 if(bgcolor) 496 if(bgcolor)
497 { 497 {
498 [bgcolor set]; 498 [bgcolor set];
499 NSRectFill( [self bounds] ); 499 NSRectFill([self bounds]);
500 } 500 }
501 } 501 }
502 -(BOOL)isFlipped { return YES; } 502 -(BOOL)isFlipped { return YES; }
503 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)1, 3); } 503 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)1, 3); }
504 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)1, 4); } 504 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)1, 4); }
507 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)3, 3); } 507 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)3, 3); }
508 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)3, 4); } 508 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)3, 4); }
509 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); _event_handler([self window], theEvent, 2); } 509 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); _event_handler([self window], theEvent, 2); }
510 -(void)setColor:(unsigned long)input 510 -(void)setColor:(unsigned long)input
511 { 511 {
512 id orig = bgcolor;
513
512 if(input == _colors[DW_CLR_DEFAULT]) 514 if(input == _colors[DW_CLR_DEFAULT])
513 { 515 {
514 bgcolor = nil; 516 bgcolor = nil;
515 } 517 }
516 else 518 else
517 { 519 {
518 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]; 520 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];
519 } 521 }
522 [orig release];
520 } 523 }
521 @end 524 @end
522 525
523 /* Subclass for a top-level window */ 526 /* Subclass for a top-level window */
524 @interface DWView : DWBox 527 @interface DWView : DWBox