mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Avoid call cycles when terminating an application.
Better NIB loading and object awakening. Remove compiler warning caused by previous change. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25614 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
daadcc3536
commit
1906ff781f
4 changed files with 337 additions and 304 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2007-11-27 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSApplication.m (-replyToApplicationShouldTerminate:):
|
||||
Check wheter the application is still running to prevent cycles.
|
||||
* Source/GSNibCompatibility.m (NSCustomObject-awakeFromNib): Call
|
||||
awakeFromNib on the instantiated object.
|
||||
* Source/GSNibCompatibility.m (NSCustomView-nibInstantiate): Move
|
||||
subviews to instantiated view.
|
||||
* Source/Functions.m (NSDrawBitmap): Remove compiler warning.
|
||||
|
||||
2007-11-24 12:38-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/GSNibCompatibility.m: Call awakeFromNib later in the nib
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <Foundation/NSProcessInfo.h>
|
||||
|
||||
#include "AppKit/NSApplication.h"
|
||||
#include "AppKit/NSBitmapImageRep.h"
|
||||
#include "AppKit/NSEvent.h"
|
||||
#include "AppKit/NSGraphicsContext.h"
|
||||
#include "AppKit/NSGraphics.h"
|
||||
|
@ -313,7 +314,7 @@ void NSDrawBitmap(NSRect rect,
|
|||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
|
||||
bitmap = [[NSBitmapImageRep alloc]
|
||||
initWithBitmapDataPlanes: data
|
||||
initWithBitmapDataPlanes: (unsigned char **)data
|
||||
pixelsWide: pixelsWide
|
||||
pixelsHigh: pixelsHigh
|
||||
bitsPerSample: bitsPerSample
|
||||
|
|
|
@ -74,14 +74,14 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
while ((v = [en nextObject]) != nil)
|
||||
{
|
||||
if ([v window] != [self window] ||
|
||||
[v superview] != self)
|
||||
{
|
||||
[v _setWindow: [self window]];
|
||||
RETAIN(v);
|
||||
[_sub_views removeObject: v];
|
||||
[self addSubview: v];
|
||||
RELEASE(v);
|
||||
}
|
||||
[v superview] != self)
|
||||
{
|
||||
[v _setWindow: [self window]];
|
||||
RETAIN(v);
|
||||
[_sub_views removeObject: v];
|
||||
[self addSubview: v];
|
||||
RELEASE(v);
|
||||
}
|
||||
[v _fixSubviews];
|
||||
}
|
||||
}
|
||||
|
@ -107,43 +107,43 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
}
|
||||
|
||||
- (id) initWithWindow: (NSWindow *)window
|
||||
className: (NSString *)windowClass
|
||||
isDeferred: (BOOL) deferred
|
||||
isOneShot: (BOOL) oneShot
|
||||
isVisible: (BOOL) visible
|
||||
className: (NSString *)windowClass
|
||||
isDeferred: (BOOL) deferred
|
||||
isOneShot: (BOOL) oneShot
|
||||
isVisible: (BOOL) visible
|
||||
wantsToBeColor: (BOOL) wantsToBeColor
|
||||
autoPositionMask: (int) autoPositionMask
|
||||
{
|
||||
if ((self = [super init]) != nil)
|
||||
{
|
||||
if (window != nil)
|
||||
{
|
||||
// object members
|
||||
ASSIGN(_title, [window title]);
|
||||
ASSIGN(_viewClass, NSStringFromClass([[window contentView] class]));
|
||||
ASSIGN(_windowClass, windowClass);
|
||||
ASSIGN(_view, [window contentView]);
|
||||
ASSIGN(_autosaveName, [window frameAutosaveName]);
|
||||
|
||||
// style & size
|
||||
_windowStyle = [window styleMask];
|
||||
_backingStoreType = [window backingType];
|
||||
_maxSize = [window maxSize];
|
||||
_minSize = [window minSize];
|
||||
_windowRect = [window frame];
|
||||
_screenRect = [[NSScreen mainScreen] frame];
|
||||
|
||||
// flags
|
||||
_flags.isHiddenOnDeactivate = [window hidesOnDeactivate];
|
||||
_flags.isNotReleasedOnClose = (![window isReleasedWhenClosed]);
|
||||
_flags.isDeferred = deferred;
|
||||
_flags.isOneShot = oneShot;
|
||||
_flags.isVisible = visible;
|
||||
_flags.wantsToBeColor = wantsToBeColor;
|
||||
_flags.dynamicDepthLimit = [window hasDynamicDepthLimit];
|
||||
_flags.autoPositionMask = autoPositionMask;
|
||||
_flags.savePosition = YES; // not yet implemented.
|
||||
}
|
||||
{
|
||||
// object members
|
||||
ASSIGN(_title, [window title]);
|
||||
ASSIGN(_viewClass, NSStringFromClass([[window contentView] class]));
|
||||
ASSIGN(_windowClass, windowClass);
|
||||
ASSIGN(_view, [window contentView]);
|
||||
ASSIGN(_autosaveName, [window frameAutosaveName]);
|
||||
|
||||
// style & size
|
||||
_windowStyle = [window styleMask];
|
||||
_backingStoreType = [window backingType];
|
||||
_maxSize = [window maxSize];
|
||||
_minSize = [window minSize];
|
||||
_windowRect = [window frame];
|
||||
_screenRect = [[NSScreen mainScreen] frame];
|
||||
|
||||
// flags
|
||||
_flags.isHiddenOnDeactivate = [window hidesOnDeactivate];
|
||||
_flags.isNotReleasedOnClose = (![window isReleasedWhenClosed]);
|
||||
_flags.isDeferred = deferred;
|
||||
_flags.isOneShot = oneShot;
|
||||
_flags.isVisible = visible;
|
||||
_flags.wantsToBeColor = wantsToBeColor;
|
||||
_flags.dynamicDepthLimit = [window hasDynamicDepthLimit];
|
||||
_flags.autoPositionMask = autoPositionMask;
|
||||
_flags.savePosition = YES; // not yet implemented.
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -154,58 +154,58 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
{
|
||||
if ([coder containsValueForKey: @"NSViewClass"])
|
||||
{
|
||||
ASSIGN(_viewClass, [coder decodeObjectForKey: @"NSViewClass"]);
|
||||
}
|
||||
ASSIGN(_viewClass, [coder decodeObjectForKey: @"NSViewClass"]);
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSWindowClass"])
|
||||
{
|
||||
ASSIGN(_windowClass, [coder decodeObjectForKey: @"NSWindowClass"]);
|
||||
}
|
||||
ASSIGN(_windowClass, [coder decodeObjectForKey: @"NSWindowClass"]);
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSWindowStyleMask"])
|
||||
{
|
||||
_windowStyle = [coder decodeIntForKey: @"NSWindowStyleMask"];
|
||||
}
|
||||
_windowStyle = [coder decodeIntForKey: @"NSWindowStyleMask"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSWindowBacking"])
|
||||
{
|
||||
_backingStoreType = [coder decodeIntForKey: @"NSWindowBacking"];
|
||||
}
|
||||
{
|
||||
_backingStoreType = [coder decodeIntForKey: @"NSWindowBacking"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSWindowView"])
|
||||
{
|
||||
ASSIGN(_view, [coder decodeObjectForKey: @"NSWindowView"]);
|
||||
}
|
||||
ASSIGN(_view, [coder decodeObjectForKey: @"NSWindowView"]);
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSWTFlags"])
|
||||
{
|
||||
unsigned long flags = [coder decodeIntForKey: @"NSWTFlags"];
|
||||
memcpy((void *)&_flags,(void *)&flags,sizeof(struct _GSWindowTemplateFlags));
|
||||
}
|
||||
unsigned long flags = [coder decodeIntForKey: @"NSWTFlags"];
|
||||
memcpy((void *)&_flags,(void *)&flags,sizeof(struct _GSWindowTemplateFlags));
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSMinSize"])
|
||||
{
|
||||
_minSize = [coder decodeSizeForKey: @"NSMinSize"];
|
||||
}
|
||||
_minSize = [coder decodeSizeForKey: @"NSMinSize"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSMaxSize"])
|
||||
{
|
||||
_maxSize = [coder decodeSizeForKey: @"NSMaxSize"];
|
||||
}
|
||||
_maxSize = [coder decodeSizeForKey: @"NSMaxSize"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSWindowRect"])
|
||||
{
|
||||
_windowRect = [coder decodeRectForKey: @"NSWindowRect"];
|
||||
}
|
||||
_windowRect = [coder decodeRectForKey: @"NSWindowRect"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSFrameAutosaveName"])
|
||||
{
|
||||
ASSIGN(_autosaveName, [coder decodeObjectForKey: @"NSFrameAutosaveName"]);
|
||||
}
|
||||
ASSIGN(_autosaveName, [coder decodeObjectForKey: @"NSFrameAutosaveName"]);
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSWindowTitle"])
|
||||
{
|
||||
ASSIGN(_title, [coder decodeObjectForKey: @"NSWindowTitle"]);
|
||||
_windowStyle |= NSTitledWindowMask;
|
||||
}
|
||||
ASSIGN(_title, [coder decodeObjectForKey: @"NSWindowTitle"]);
|
||||
_windowStyle |= NSTitledWindowMask;
|
||||
}
|
||||
|
||||
_baseWindowClass = [NSWindow class];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
{
|
||||
unsigned long flags = 0;
|
||||
NSRect rect = [NSWindow contentRectForFrameRect: _windowRect
|
||||
styleMask: _windowStyle];
|
||||
styleMask: _windowStyle];
|
||||
memcpy((void *)&flags,(void *)&_flags,sizeof(unsigned long));
|
||||
|
||||
[aCoder encodeObject: _viewClass forKey: @"NSViewClass"];
|
||||
|
@ -242,26 +242,26 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
id v = nil;
|
||||
|
||||
if ([NSClassSwapper isInInterfaceBuilder])
|
||||
{
|
||||
aClass = [self baseWindowClass];
|
||||
}
|
||||
{
|
||||
aClass = [self baseWindowClass];
|
||||
}
|
||||
else
|
||||
{
|
||||
aClass = NSClassFromString(_windowClass);
|
||||
}
|
||||
{
|
||||
aClass = NSClassFromString(_windowClass);
|
||||
}
|
||||
|
||||
if (aClass == nil)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to find class '%@'", _windowClass];
|
||||
}
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to find class '%@'", _windowClass];
|
||||
}
|
||||
|
||||
_realObject = [[aClass allocWithZone: NSDefaultMallocZone()]
|
||||
initWithContentRect: _windowRect
|
||||
styleMask: _windowStyle
|
||||
backing: _backingStoreType
|
||||
defer: _flags.isDeferred
|
||||
screen: nil];
|
||||
initWithContentRect: _windowRect
|
||||
styleMask: _windowStyle
|
||||
backing: _backingStoreType
|
||||
defer: _flags.isDeferred
|
||||
screen: nil];
|
||||
|
||||
// set flags...
|
||||
[_realObject setHidesOnDeactivate: _flags.isHiddenOnDeactivate];
|
||||
|
@ -286,18 +286,18 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
|
||||
// resize the window...
|
||||
[_realObject setFrame: [NSWindow frameRectForContentRect: [self windowRect]
|
||||
styleMask: [self windowStyle]]
|
||||
display: NO];
|
||||
styleMask: [self windowStyle]]
|
||||
display: NO];
|
||||
|
||||
// swap out any views which need to be swapped...
|
||||
en = [[[_realObject contentView] subviews] objectEnumerator];
|
||||
while ((v = [en nextObject]) != nil)
|
||||
{
|
||||
if ([v respondsToSelector: @selector(nibInstantiate)])
|
||||
{
|
||||
[v nibInstantiate];
|
||||
}
|
||||
}
|
||||
{
|
||||
if ([v respondsToSelector: @selector(nibInstantiate)])
|
||||
{
|
||||
[v nibInstantiate];
|
||||
}
|
||||
}
|
||||
}
|
||||
return _realObject;
|
||||
}
|
||||
|
@ -440,15 +440,15 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
if (self != nil)
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
_className = [coder decodeObjectForKey: @"NSClassName"];
|
||||
}
|
||||
{
|
||||
_className = [coder decodeObjectForKey: @"NSClassName"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -467,15 +467,15 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
{
|
||||
Class aClass = NSClassFromString(_className);
|
||||
if (aClass == nil)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to find class '%@'", _className];
|
||||
}
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to find class '%@'", _className];
|
||||
}
|
||||
else
|
||||
{
|
||||
_realObject = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]];
|
||||
[[self superview] replaceSubview: self with: _realObject]; // replace the old view...
|
||||
}
|
||||
{
|
||||
_realObject = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]];
|
||||
[[self superview] replaceSubview: self with: _realObject]; // replace the old view...
|
||||
}
|
||||
}
|
||||
|
||||
return _realObject;
|
||||
|
@ -525,15 +525,15 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
{
|
||||
Class aClass = NSClassFromString(_className);
|
||||
if (aClass == nil)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to find class '%@'", _className];
|
||||
}
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to find class '%@'", _className];
|
||||
}
|
||||
else
|
||||
{
|
||||
_realObject = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]];
|
||||
[[self superview] replaceSubview: self with: _realObject]; // replace the old view...
|
||||
}
|
||||
{
|
||||
_realObject = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]];
|
||||
[[self superview] replaceSubview: self with: _realObject]; // replace the old view...
|
||||
}
|
||||
}
|
||||
|
||||
return _realObject;
|
||||
|
@ -621,8 +621,8 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -637,8 +637,8 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Keyed coding not implemented for %@.",
|
||||
NSStringFromClass([self class])];
|
||||
format: @"Keyed coding not implemented for %@.",
|
||||
NSStringFromClass([self class])];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -650,25 +650,33 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
Class aClass;
|
||||
|
||||
if ([NSClassSwapper isInInterfaceBuilder])
|
||||
{
|
||||
aClass = [self class];
|
||||
}
|
||||
{
|
||||
aClass = [self class];
|
||||
}
|
||||
else
|
||||
{
|
||||
aClass = NSClassFromString(_className);
|
||||
}
|
||||
{
|
||||
aClass = NSClassFromString(_className);
|
||||
}
|
||||
|
||||
if (aClass == nil)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to find class '%@'", _className];
|
||||
}
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to find class '%@'", _className];
|
||||
}
|
||||
|
||||
_object = [[aClass allocWithZone: NSDefaultMallocZone()] init];
|
||||
}
|
||||
return _object;
|
||||
}
|
||||
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
if ([_object respondsToSelector: @selector(awakeFromNib)])
|
||||
{
|
||||
[_object awakeFromNib];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_className);
|
||||
|
@ -704,26 +712,39 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
Class aClass;
|
||||
|
||||
if ([NSClassSwapper isInInterfaceBuilder])
|
||||
{
|
||||
aClass = [self class];
|
||||
}
|
||||
{
|
||||
aClass = [self class];
|
||||
}
|
||||
else
|
||||
{
|
||||
aClass = NSClassFromString(_className);
|
||||
}
|
||||
{
|
||||
aClass = NSClassFromString(_className);
|
||||
}
|
||||
|
||||
if (aClass == nil)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to find class '%@'", _className];
|
||||
}
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to find class '%@'", _className];
|
||||
}
|
||||
else
|
||||
{
|
||||
_view = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]];
|
||||
[_view setAutoresizingMask: [self autoresizingMask]];
|
||||
[_view setNextResponder: [self nextResponder]];
|
||||
[[self superview] replaceSubview: self with: _view]; // replace the old view...
|
||||
}
|
||||
{
|
||||
_view = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]];
|
||||
[_view setAutoresizingMask: [self autoresizingMask]];
|
||||
[self setAutoresizesSubviews: [self autoresizesSubviews]];
|
||||
[self setHidden: [self isHidden]];
|
||||
[_view setNextResponder: [self nextResponder]];
|
||||
[[self superview] replaceSubview: self with: _view]; // replace the old view...
|
||||
if (_rFlags.has_subviews)
|
||||
{
|
||||
NSArray *subviews = [self subviews];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < [subviews count]; i++)
|
||||
{
|
||||
[_view addSubview: [subviews objectAtIndex: i]];
|
||||
}
|
||||
}
|
||||
// FIXME: Need to transfer all other settings as well
|
||||
}
|
||||
}
|
||||
|
||||
return _view;
|
||||
|
@ -735,16 +756,16 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
if (self != nil)
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]);
|
||||
ASSIGN(_extension, [coder decodeObjectForKey: @"NSExtension"]);
|
||||
}
|
||||
{
|
||||
ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]);
|
||||
ASSIGN(_extension, [coder decodeObjectForKey: @"NSExtension"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -760,8 +781,8 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
@ -802,25 +823,25 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
|
||||
// this is a hack, but for now it should do.
|
||||
if ([_className isEqual: @"NSSound"])
|
||||
{
|
||||
realObject = RETAIN([NSSound soundNamed: _resourceName]);
|
||||
}
|
||||
{
|
||||
realObject = RETAIN([NSSound soundNamed: _resourceName]);
|
||||
}
|
||||
else if ([_className isEqual: @"NSImage"])
|
||||
{
|
||||
realObject = RETAIN([NSImage imageNamed: _resourceName]);
|
||||
}
|
||||
{
|
||||
realObject = RETAIN([NSImage imageNamed: _resourceName]);
|
||||
}
|
||||
|
||||
// if an object has been substituted, then release the placeholder.
|
||||
if (realObject != nil)
|
||||
{
|
||||
RELEASE(self);
|
||||
}
|
||||
{
|
||||
RELEASE(self);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
|
||||
return realObject;
|
||||
|
@ -850,7 +871,7 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
{
|
||||
id obj = GSIArrayItemAtIndex(_objMap, i).obj;
|
||||
if (obj == oldObj)
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
if (i < count)
|
||||
|
@ -939,7 +960,7 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
if (aClass == nil)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"NSClassSwapper unable to find class '%@'", className];
|
||||
format: @"NSClassSwapper unable to find class '%@'", className];
|
||||
}
|
||||
|
||||
// if this is a class which uses cells, override with the new cellClass, if the
|
||||
|
@ -979,19 +1000,19 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
|
||||
// build the real object...
|
||||
if ([NSClassSwapper isInInterfaceBuilder] == YES)
|
||||
{
|
||||
[self instantiateRealObject: coder withClassName: _originalClassName];
|
||||
}
|
||||
{
|
||||
[self instantiateRealObject: coder withClassName: _originalClassName];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self instantiateRealObject: coder withClassName: _className];
|
||||
}
|
||||
{
|
||||
[self instantiateRealObject: coder withClassName: _className];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
|
||||
return _template;
|
||||
|
@ -1008,8 +1029,8 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1073,10 +1094,10 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
while ((obj = [en nextObject]) != nil)
|
||||
{
|
||||
if ([obj respondsToSelector: @selector(instantiateWithInstantiator:)])
|
||||
{
|
||||
[obj instantiateWithInstantiator: self];
|
||||
[obj establishConnection];
|
||||
}
|
||||
{
|
||||
[obj instantiateWithInstantiator: self];
|
||||
[obj establishConnection];
|
||||
}
|
||||
}
|
||||
|
||||
// iterate over all objects instantiate windows, awaken objects and fill
|
||||
|
@ -1086,27 +1107,27 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
{
|
||||
// instantiate all windows and fill in the top level array.
|
||||
if ([obj isKindOfClass: [NSWindowTemplate class]])
|
||||
{
|
||||
if ([obj realObject] == nil)
|
||||
{
|
||||
obj = [self instantiateObject: obj];
|
||||
[topLevelObjects addObject: obj];
|
||||
}
|
||||
}
|
||||
{
|
||||
if ([obj realObject] == nil)
|
||||
{
|
||||
obj = [self instantiateObject: obj];
|
||||
[topLevelObjects addObject: obj];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
id v = NSMapGet(_objects, obj);
|
||||
if (v == nil || v == owner)
|
||||
{
|
||||
[topLevelObjects addObject: obj];
|
||||
}
|
||||
}
|
||||
{
|
||||
id v = NSMapGet(_objects, obj);
|
||||
if (v == nil || v == owner)
|
||||
{
|
||||
[topLevelObjects addObject: obj];
|
||||
}
|
||||
}
|
||||
|
||||
// awaken the object.
|
||||
if ([obj respondsToSelector: @selector(awakeFromNib)])
|
||||
{
|
||||
[obj awakeFromNib];
|
||||
}
|
||||
{
|
||||
[obj awakeFromNib];
|
||||
}
|
||||
}
|
||||
|
||||
// bring visible windows to front...
|
||||
|
@ -1251,14 +1272,14 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _buildMap: (NSMapTable *)mapTable
|
||||
withKeys: (NSArray *)keys
|
||||
andValues: (NSArray *)values
|
||||
withKeys: (NSArray *)keys
|
||||
andValues: (NSArray *)values
|
||||
{
|
||||
NSEnumerator *ken = [keys objectEnumerator];
|
||||
NSEnumerator *ven = [values objectEnumerator];
|
||||
|
@ -1283,67 +1304,67 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
_nextOid = [coder decodeIntForKey: @"NSNextOid"];
|
||||
|
||||
{
|
||||
NSArray *objectsKeys = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSObjectsKeys"];
|
||||
NSArray *objectsValues = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSObjectsValues"];
|
||||
NSArray *nameKeys = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSNamesKeys"];
|
||||
NSArray *nameValues = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSNamesValues"];
|
||||
NSArray *oidsKeys = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSOidsKeys"];
|
||||
NSArray *oidsValues = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSOidsValues"];
|
||||
NSArray *classKeys = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSClassesKeys"];
|
||||
NSArray *classValues = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSClassesValues"];
|
||||
NSArray *accessibilityOidsKeys = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSAccessibilityOidsKeys"];
|
||||
NSArray *accessibilityOidsValues = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSAccessibilityOidsValues"];
|
||||
|
||||
// instantiate the maps..
|
||||
_objects = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
_names = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
_oids = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
_classes = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
_accessibilityOids = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
|
||||
// fill in the maps...
|
||||
[self _buildMap: _accessibilityOids
|
||||
withKeys: accessibilityOidsKeys
|
||||
andValues: accessibilityOidsValues];
|
||||
[self _buildMap: _classes
|
||||
withKeys: classKeys
|
||||
andValues: classValues];
|
||||
[self _buildMap: _names
|
||||
withKeys: nameKeys
|
||||
andValues: nameValues];
|
||||
[self _buildMap: _objects
|
||||
withKeys: objectsKeys
|
||||
andValues: objectsValues];
|
||||
[self _buildMap: _oids
|
||||
withKeys: oidsKeys
|
||||
andValues: oidsValues];
|
||||
NSArray *objectsKeys = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSObjectsKeys"];
|
||||
NSArray *objectsValues = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSObjectsValues"];
|
||||
NSArray *nameKeys = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSNamesKeys"];
|
||||
NSArray *nameValues = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSNamesValues"];
|
||||
NSArray *oidsKeys = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSOidsKeys"];
|
||||
NSArray *oidsValues = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSOidsValues"];
|
||||
NSArray *classKeys = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSClassesKeys"];
|
||||
NSArray *classValues = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSClassesValues"];
|
||||
NSArray *accessibilityOidsKeys = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSAccessibilityOidsKeys"];
|
||||
NSArray *accessibilityOidsValues = (NSArray *)
|
||||
[coder decodeObjectForKey: @"NSAccessibilityOidsValues"];
|
||||
|
||||
// instantiate the maps..
|
||||
_objects = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
_names = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
_oids = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
_classes = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
_accessibilityOids = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
|
||||
// fill in the maps...
|
||||
[self _buildMap: _accessibilityOids
|
||||
withKeys: accessibilityOidsKeys
|
||||
andValues: accessibilityOidsValues];
|
||||
[self _buildMap: _classes
|
||||
withKeys: classKeys
|
||||
andValues: classValues];
|
||||
[self _buildMap: _names
|
||||
withKeys: nameKeys
|
||||
andValues: nameValues];
|
||||
[self _buildMap: _objects
|
||||
withKeys: objectsKeys
|
||||
andValues: objectsValues];
|
||||
[self _buildMap: _oids
|
||||
withKeys: oidsKeys
|
||||
andValues: oidsValues];
|
||||
|
||||
ASSIGN(_connections, [[coder decodeObjectForKey: @"NSConnections"] mutableCopy]);
|
||||
ASSIGN(_connections, [[coder decodeObjectForKey: @"NSConnections"] mutableCopy]);
|
||||
|
||||
// instantiate...
|
||||
_topLevelObjects = [[NSMutableSet alloc] init];
|
||||
// instantiate...
|
||||
_topLevelObjects = [[NSMutableSet alloc] init];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -1355,15 +1376,15 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
{
|
||||
// instantiate the maps..
|
||||
_objects = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
_names = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
_oids = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
_classes = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
_accessibilityOids = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
|
||||
// initialize the objects...
|
||||
_accessibilityConnectors = [[NSMutableArray alloc] init];
|
||||
|
@ -1428,8 +1449,8 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
|
||||
RELEASE(self);
|
||||
|
@ -1445,8 +1466,8 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1487,21 +1508,21 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
if ((self = [super initWithCoder: coder]) != nil)
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
if ([coder containsValueForKey: @"NSFile"])
|
||||
{
|
||||
_file = RETAIN([coder decodeObjectForKey: @"NSFile"]);
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSMarker"])
|
||||
{
|
||||
_marker = RETAIN([coder decodeObjectForKey: @"NSMarker"]);
|
||||
}
|
||||
}
|
||||
{
|
||||
if ([coder containsValueForKey: @"NSFile"])
|
||||
{
|
||||
_file = RETAIN([coder decodeObjectForKey: @"NSFile"]);
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSMarker"])
|
||||
{
|
||||
_marker = RETAIN([coder decodeObjectForKey: @"NSMarker"]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_file = RETAIN([coder decodeObject]);
|
||||
_marker = RETAIN([coder decodeObject]);
|
||||
}
|
||||
{
|
||||
_file = RETAIN([coder decodeObject]);
|
||||
_marker = RETAIN([coder decodeObject]);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -1512,13 +1533,13 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
if (_file != nil)
|
||||
{
|
||||
[coder encodeObject: _file forKey: @"NSFile"];
|
||||
}
|
||||
{
|
||||
[coder encodeObject: _file forKey: @"NSFile"];
|
||||
}
|
||||
if (_marker != nil)
|
||||
{
|
||||
[coder encodeObject: _file forKey: @"NSMarker"];
|
||||
}
|
||||
{
|
||||
[coder encodeObject: _file forKey: @"NSMarker"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1576,20 +1597,20 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
memcpy((void *)&unswapped, (void *)mantissaBytes, sizeof(unsigned long long));
|
||||
|
||||
switch(bo)
|
||||
{
|
||||
case NS_BigEndian:
|
||||
mantissa = NSSwapBigLongLongToHost(unswapped);
|
||||
break;
|
||||
case NS_LittleEndian:
|
||||
mantissa = NSSwapLittleLongLongToHost(unswapped);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
{
|
||||
case NS_BigEndian:
|
||||
mantissa = NSSwapBigLongLongToHost(unswapped);
|
||||
break;
|
||||
case NS_LittleEndian:
|
||||
mantissa = NSSwapLittleLongLongToHost(unswapped);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
dn = [[NSDecimalNumber alloc] initWithMantissa: mantissa
|
||||
exponent: exponent
|
||||
isNegative: negative];
|
||||
exponent: exponent
|
||||
isNegative: negative];
|
||||
}
|
||||
return dn;
|
||||
}
|
||||
|
|
|
@ -3221,7 +3221,8 @@ struct _DelegateWrapper
|
|||
*/
|
||||
- (void) replyToApplicationShouldTerminate: (BOOL)shouldTerminate
|
||||
{
|
||||
if (shouldTerminate)
|
||||
// Prevent cycles in terminate: call.
|
||||
if (shouldTerminate && _app_is_running)
|
||||
{
|
||||
[nc postNotificationName: NSApplicationWillTerminateNotification
|
||||
object: self];
|
||||
|
@ -3241,20 +3242,20 @@ struct _DelegateWrapper
|
|||
userInfo: [self _notificationUserInfo]];
|
||||
|
||||
/* Destroy the main run loop pool (this also destroys any nested
|
||||
pools which might have been created inside this one). */
|
||||
pools which might have been created inside this one). */
|
||||
DESTROY (_runLoopPool);
|
||||
|
||||
/* Now free the NSApplication object. Enclose the operation
|
||||
into an autorelease pool, in case some -dealloc method needs
|
||||
to use any temporary object. */
|
||||
into an autorelease pool, in case some -dealloc method needs
|
||||
to use any temporary object. */
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
IF_NO_GC(pool = [arpClass new]);
|
||||
IF_NO_GC(pool = [arpClass new]);
|
||||
|
||||
DESTROY(NSApp);
|
||||
DESTROY(NSApp);
|
||||
|
||||
DESTROY(pool);
|
||||
DESTROY(pool);
|
||||
}
|
||||
|
||||
/* And finally, stop the program. */
|
||||
|
|
Loading…
Reference in a new issue