Implement NSApplication's -context method.

Add global variable to NSApplication to prevent -release loops when
it is being dealloced.
Remove debugging information.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@1634 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
GNUstep Maintainer 1996-06-06 13:55:06 +00:00
parent 31d363516e
commit 64f0e88fd0
6 changed files with 48 additions and 48 deletions

View file

@ -1,3 +1,16 @@
Thu Jun 6 09:20:51 1996 GNUstep Development <gnustep@duncan.ocbi.com>
* Headers/gnustep/gui/NSApplication.h (-context): New method.
* Source/Makefile.sed.nt (install): Delete AppKit and DPSClient
headers directories before installing headers.
* Source/NSApplication.m (gnustep_gui_app_is_in_dealloc): New
global variable to flag when the application is being dealloced
so it can prevent -release loops.
(+initialize, -dealloc, -removeWindowsItem:): Likewise.
(-context): New method.
* Source/NSView.m (+pushFocusView, +focusView): Remove
debugging information.
Mon Jun 3 10:54:28 1996 GNUstep Development <gnustep@duncan.ocbi.com>
* Makefile.in (clean-top, distclean): Correct targets and clean

View file

@ -41,6 +41,7 @@
#include <Foundation/NSDate.h>
#include <gnustep/base/Queue.h>
#include <Foundation/NSCoder.h>
#include <DPSClient/NSDPSContext.h>
@interface NSApplication : NSResponder <NSCoding>
@ -196,7 +197,7 @@
//
// Getting the display postscript context
//
// - (NSDOSContext *)context;
- (NSDPSContext *)context;
//
// Reporting an exception

View file

@ -54,7 +54,9 @@ install-headers:\
for %i in ( $(GNUSTEP_DPS_HEADERS) ) do \\\
( $(INSTALL_DATA) ../Headers/gnustep/%i \\\
$(includedir)/gnustep/%i ) \
IF EXIST $(includedir)\\AppKit rm -rf $(includedir)/AppKit \
cp -r $(includedir)/gnustep/gui $(includedir)/AppKit \
IF EXIST $(includedir)\\DPSClient rm -rf $(includedir)/DPSClient \
cp -r $(includedir)/gnustep/dps $(includedir)/DPSClient \
# end of install targets

View file

@ -39,6 +39,7 @@
// The global application instance
extern id NSApp;
NSEvent *NullEvent;
BOOL gnustep_gui_app_is_in_dealloc;
// Global strings
NSString *NSModalPanelRunLoopMode = @"ModalPanelMode";
@ -111,6 +112,10 @@ NSString *NSApplicationWillUpdateNotification;
// Initial version
[self setVersion:1];
// So the application knows its within dealloc
// and can prevent -release loops.
gnustep_gui_app_is_in_dealloc = NO;
}
}
@ -154,9 +159,6 @@ NSString *NSApplicationWillUpdateNotification;
//
[self setNextResponder:NULL];
// Finish the Launching
[self finishLaunching];
return self;
}
@ -177,15 +179,18 @@ NSString *NSApplicationWillUpdateNotification;
//NSLog(@"Freeing NSApplication\n");
// Let ourselves know we are within dealloc
gnustep_gui_app_is_in_dealloc = YES;
// Release the window list
// We retain all of the objects in our list
// so we need to release them
//NSArray doesn't know -removeAllObjects yet
//[window_list removeAllObjects];
j = [window_list count];
for (i = 0;i < j; ++i)
[[window_list objectAtIndex:i] release];
[window_list removeAllObjects];
//j = [window_list count];
//for (i = 0;i < j; ++i)
// [[window_list objectAtIndex:i] release];
// no need -array is autoreleased
//[window_list release];
@ -713,10 +718,7 @@ NSString *NSApplicationWillUpdateNotification;
if (![aWindow isKindOfClass:[NSWindow class]])
return;
// Retain the window
//[aWindow retain];
// Add to our window list
// Add to our window list, the array retains it
i = [window_list count];
[window_list addObject:aWindow];
@ -748,26 +750,21 @@ NSString *NSApplicationWillUpdateNotification;
int i, j;
id w;
// This should be different
// +++ This should be different
if (aWindow == key_window)
key_window = nil;
if (aWindow == main_window)
main_window = nil;
// Simple -find it and remove it
j = [window_list count];
for (i = 0;i < j; ++i)
{
w = [window_list objectAtIndex:i];
if (w == aWindow)
{
// Remove from out list
[window_list removeObjectAtIndex:i];
// Release it because we retained it before
//[w release];
return;
}
}
// If we are within our dealloc then don't remove the window
// Most likely dealloc is removing windows from our window list
// and subsequently NSWindow is caling us to remove itself.
if (gnustep_gui_app_is_in_dealloc)
return;
// Remove it from the window list
[window_list removeObject: aWindow];
return;
}
@ -810,7 +807,10 @@ NSString *NSApplicationWillUpdateNotification;
}
// Getting the display postscript context
// - (NSDOSContext *)context;
- (NSDPSContext *)context
{
return [NSDPSContext currentContext];
}
// Reporting an exception
//- (void)reportException:(NSException *)anException

View file

@ -140,7 +140,7 @@ BOOL GNU_CONTEXT_SYNCHRONIZED;
NSLog(@"NSDPSContext: +currentContext\n");
// Get current context for current thread
[GNU_CONTEXT_LOCK lock];
NSLog(@"NSDPSContext: enter critical section\n");
current_context = [GNU_CONTEXT_THREAD_DICT objectForKey: current_thread];
NSLog(@"NSDPSContext: Looked in context dictionary\n");
@ -170,12 +170,10 @@ BOOL GNU_CONTEXT_SYNCHRONIZED;
// If no context then remove from dictionary
if (!context)
{
NSLog(@"NSDPSContext: remove from dictionary\n");
[GNU_CONTEXT_THREAD_DICT removeObjectForKey: current_thread];
}
else
{
NSLog(@"NSDPSContext: add to dictionary\n");
[GNU_CONTEXT_THREAD_DICT setObject: context
forKey: current_thread];
}

View file

@ -79,26 +79,21 @@ NSString *NSViewFocusChangedNotification;
{
NSThread *current_thread = [NSThread currentThread];
NSLog(@"NSView: +pushFocusView\n");
// Obtain lock so we can edit the dictionary
[gnustep_gui_nsview_lock lock];
NSLog(@"NSView: enter critical section\n");
// If no context then remove from dictionary
if (!focusView)
{
NSLog(@"NSView: remove from dictionary\n");
[gnustep_gui_nsview_thread_dict removeObjectForKey: current_thread];
}
else
{
NSLog(@"NSView: add to dictionary\n");
[gnustep_gui_nsview_thread_dict setObject: focusView
forKey: current_thread];
}
[gnustep_gui_nsview_lock unlock];
NSLog(@"NSView: exit critical section\n");
NSLog(@"NSView: return from +pushFocusView\n");
}
+ (NSView *)popFocusView
@ -109,23 +104,14 @@ NSString *NSViewFocusChangedNotification;
NSThread *current_thread = [NSThread currentThread];
NSView *current_view = nil;
NSLog(@"NSView: +focusView\n");
// Get focused view for current thread
[gnustep_gui_nsview_lock lock];
NSLog(@"NSView: enter critical section\n");
current_view = [gnustep_gui_nsview_thread_dict objectForKey: current_thread];
NSLog(@"NSView: Looked in view dictionary\n");
// If not in dictionary then no focused view
if (!current_view)
NSLog(@"NSView: Did not find a view\n");
else
NSLog(@"NSView: Found a view\n");
// current_view is nil if no focused view
current_view = [gnustep_gui_nsview_thread_dict objectForKey: current_thread];
[gnustep_gui_nsview_lock unlock];
NSLog(@"NSView: exit critical section\n");
NSLog(@"NSView: return from +focusView\n");
return current_view;
}