From 2b18227eb0760c6e260a10e8fe03cc86a6ae73bc Mon Sep 17 00:00:00 2001 From: rfm Date: Sat, 31 Jan 2009 06:17:29 +0000 Subject: [PATCH] fix for #25385 git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27741 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/GSToolTips.m | 36 +++++++++++++++++++++--------------- Source/NSToolbar.m | 24 ++++++++++++++++-------- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index fd109e80f..eb445c131 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-01-31 Richard Frith-Macdonald + + * Source/GSToolTips.m: Fix retain/release problem. + * Source/NSToolbar.m: Add exception handler round unsafe code. + 2009-01-30 Richard Frith-Macdonald * Source/GSThemeTools.m: Add checks to prevent problems in the case diff --git a/Source/GSToolTips.m b/Source/GSToolTips.m index 36e537c05..73d120f17 100644 --- a/Source/GSToolTips.m +++ b/Source/GSToolTips.m @@ -73,17 +73,33 @@ } - (void) dealloc { + [self setObject: nil]; + [super dealloc]; +} +- (id) initWithObject: (id)o userData: (void*)d rect: (NSRect)r +{ + data = d; + viewRect = r; + [self setObject: o]; + return self; +} +- (id) object +{ + return object; +} +- (void) setObject: (id)o +{ + /* Experimentation on MacOS-X shows that the object is not retained. + * However, if the object does not provide a string, we must use a + * copy of its description ... and we have to retain that until we + * are done with it. + */ if ([object respondsToSelector: @selector(view:stringForToolTip:point:userData:)] == NO) { /* Object must be a string rather than something which provides one */ RELEASE(object); } - [super dealloc]; -} -- (id) initWithObject: (id)o userData: (void*)d rect: (NSRect)r -{ - data = d; object = o; if ([object respondsToSelector: @selector(view:stringForToolTip:point:userData:)] == NO) @@ -93,16 +109,6 @@ */ object = [[object description] copy]; } - viewRect = r; - return self; -} -- (id) object -{ - return object; -} -- (void) setObject: (id)o -{ - object = o; } - (NSRect) viewRect { diff --git a/Source/NSToolbar.m b/Source/NSToolbar.m index 3f468a7e3..6916dbaa7 100644 --- a/Source/NSToolbar.m +++ b/Source/NSToolbar.m @@ -270,14 +270,22 @@ static GSValidationCenter *vc = nil; - (void) validate { - _validating = YES; - - // NSLog(@"vobj validate"); - - [_observers makeObjectsPerformSelector: @selector(_validate:) - withObject: _window]; - - _validating = NO; + if (_validating == NO) + { + _validating = YES; + NS_DURING + { + [_observers makeObjectsPerformSelector: @selector(_validate:) + withObject: _window]; + _validating = NO; + } + NS_HANDLER + { + _validating = NO; + NSLog(@"Problem validating toolbar: %@", localException); + } + NS_ENDHANDLER + } } - (void) mouseEntered: (NSEvent *)event