From 00bc3151f27c9f5836e2fd04011d539212bb7bb8 Mon Sep 17 00:00:00 2001 From: richard Date: Tue, 27 Oct 1998 16:01:33 +0000 Subject: [PATCH] pushFocusView: must be given an object. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3134 72102866-910b-0410-8b05-ffd578937521 --- Source/NSView.m | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/NSView.m b/Source/NSView.m index 083981c13..4c8facd2a 100644 --- a/Source/NSView.m +++ b/Source/NSView.m @@ -70,14 +70,23 @@ static NSString *nsview_thread_key = @"NSViewThreadKey"; if (stack == nil) { - stack = [[NSMutableDictionary alloc] initWithCapacity: 4]; + stack = [[NSMutableArray alloc] initWithCapacity: 4]; [dict setObject: stack forKey: nsview_thread_key]; [stack release]; } [stack addObject: focusView]; } + else + { + [NSException raise: NSInternalInconsistencyException + format: @"Attempt to push a 'nil' focus view on to stack."]; + } } +/* + * Remove the top focusView for the current thread from the stack + * and return the new focusView (or nil if the stack is now empty). + */ + (NSView *)popFocusView { NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary]; @@ -88,10 +97,13 @@ static NSString *nsview_thread_key = @"NSViewThreadKey"; { unsigned count = [stack count]; + if (count > 0) + { + [stack removeObjectAtIndex: --count]; + } if (count > 0) { v = [stack objectAtIndex: --count]; - [stack removeObjectAtIndex: count]; } } return v;