Don't encode the superview when encoding the contentView of a window, since it can be a subview of the GS decoration views. Correct type for visibleWindows, should be NSArray, not NSSet.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23204 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2006-08-05 12:46:20 +00:00
parent d0d68dd618
commit fb8609cf7a
4 changed files with 73 additions and 22 deletions

View file

@ -1,3 +1,11 @@
2006-08-05 08:43-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Headers/Additions/GNUstepGUI/GSNibCompatibility.h
* Source/GSNibCompatibility.m: Changed visibleWindows to an Array, as
it should be.
* Source/NSView.m: Avoid encoding of super_view in encodeWithCoder: if
it is the contentView of the window.
2006-07-21 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTextView.m (-setTypingAttributes:): Make sure to keep

View file

@ -107,7 +107,7 @@ typedef struct _GSWindowTemplateFlags
}
- (id) initWithWindow: (NSWindow *)window
className: (NSString *)windowClass
isDefferred: (BOOL) deferred
isDeferred: (BOOL) deferred
isOneShot: (BOOL) oneShot
isVisible: (BOOL) visible
wantsToBeColor: (BOOL) wantsToBeColor
@ -216,12 +216,17 @@ typedef struct _GSWindowTemplateFlags
NSString *_originalClassName;
id _template;
}
- (id) initWithObject: (id)object
withClassName: (NSString *)className
originalClassName: (NSString *)origClassName;
+ (void) setIsInInterfaceBuilder: (BOOL)flag;
+ (BOOL) isInInterfaceBuilder;
- (void) setTemplate: (id)temp;
- (id) template;
- (void) setClassName: (NSString *)className;
- (NSString *)className;
- (void) setOriginalClassName: (NSString *)className;
- (NSString *)originalClassName;
@end
@interface NSIBObjectData : NSObject <NSCoding, GSInstantiator, GSNibContainer>
@ -232,7 +237,7 @@ typedef struct _GSWindowTemplateFlags
NSMapTable *_oids;
NSMapTable *_classes;
NSMapTable *_instantiatedObjs;
NSMutableSet *_visibleWindows;
NSMutableArray *_visibleWindows;
NSMutableArray *_connections;
id _firstResponder;
id _fontManager;
@ -250,7 +255,11 @@ typedef struct _GSWindowTemplateFlags
- (NSMapTable *) objects;
- (NSMapTable *) names;
- (NSMapTable *) classes;
- (NSArray *) visibleWindows;
- (NSMutableArray *) visibleWindows;
- (void) setRoot: (id)root;
- (id) root;
- (void) setNextOid: (int)noid;
- (int) nextOid;
@end
#endif /* _GNUstep_H_GSNibCompatibility */

View file

@ -61,11 +61,6 @@ static BOOL _isInInterfaceBuilder = NO;
@end
@implementation NSView (NibCompatibility)
- (void) _setSuperview: (id) sv
{
ASSIGN(_super_view,sv);
}
- (void) _setWindow: (id) w
{
ASSIGN(_window,w);
@ -81,7 +76,10 @@ static BOOL _isInInterfaceBuilder = NO;
[v superview] != self)
{
[v _setWindow: [self window]];
[v _setSuperview: self];
RETAIN(v);
[_sub_views removeObject: v];
[self addSubview: v];
RELEASE(v);
}
[v _fixSubviews];
}
@ -109,7 +107,7 @@ static BOOL _isInInterfaceBuilder = NO;
- (id) initWithWindow: (NSWindow *)window
className: (NSString *)windowClass
isDefferred: (BOOL) deferred
isDeferred: (BOOL) deferred
isOneShot: (BOOL) oneShot
isVisible: (BOOL) visible
wantsToBeColor: (BOOL) wantsToBeColor
@ -233,12 +231,6 @@ static BOOL _isInInterfaceBuilder = NO;
}
}
- (void) _fixSubviews
{
id view = [_realObject contentView];
[view _fixSubviews];
}
- (id) nibInstantiate
{
if(_realObject == nil)
@ -288,7 +280,7 @@ static BOOL _isInInterfaceBuilder = NO;
[_realObject setMaxSize: _maxSize];
[_realObject setTitle: _title];
[self _fixSubviews];
[_view _fixSubviews];
// resize the window...
[_realObject setFrame: [NSWindow frameRectForContentRect: [self windowRect]
@ -865,6 +857,19 @@ static BOOL _isInInterfaceBuilder = NO;
@end
@implementation NSClassSwapper
- (id) initWithObject: (id)object
withClassName: (NSString *)className
originalClassName: (NSString *)origClassName
{
if((self = [super init]) != nil)
{
[self setTemplate: object];
[self setClassName: className];
[self setOriginalClassName: origClassName];
}
return self;
}
+ (void) setIsInInterfaceBuilder: (BOOL)flag
{
_isInInterfaceBuilder = flag;
@ -895,6 +900,16 @@ static BOOL _isInInterfaceBuilder = NO;
return _className;
}
- (void) setOriginalClassName: (NSString *)className
{
ASSIGN(_originalClassName, className);
}
- (NSString *)originalClassName
{
return _originalClassName;
}
- (void) instantiateRealObject: (NSCoder *)coder withClassName: (NSString *)className
{
Class aClass = nil;
@ -931,7 +946,7 @@ static BOOL _isInInterfaceBuilder = NO;
// swap the class...
object = [aClass allocWithZone: NSDefaultMallocZone()];
[(NSKeyedUnarchiver *)coder replaceObject: self withObject: object];
_template = [object initWithCoder: coder];
[self setTemplate: [object initWithCoder: coder]];
if(object != _template)
{
[(NSKeyedUnarchiver *)coder replaceObject: object withObject: _template];
@ -977,6 +992,7 @@ static BOOL _isInInterfaceBuilder = NO;
NSString *originalClassName = NSStringFromClass(_template);
[coder encodeObject: (id)_className forKey: @"NSClassName"];
[coder encodeObject: (id)originalClassName forKey: @"NSOriginalClassName"];
[_template encodeWithCoder: coder]; // encode the actual object;
}
else
{
@ -1118,9 +1134,9 @@ static BOOL _isInInterfaceBuilder = NO;
return nil;
}
- (NSArray *) visibleWindows
- (NSMutableArray *) visibleWindows
{
return [_visibleWindows allObjects];
return _visibleWindows;
}
- (NSMapTable *) objects
@ -1243,7 +1259,6 @@ static BOOL _isInInterfaceBuilder = NO;
ASSIGN(_accessibilityConnectors, (NSMutableArray *)[coder decodeObjectForKey: @"NSAccessibilityConnectors"]);
ASSIGN(_fontManager, [coder decodeObjectForKey: @"NSFontManager"]);
ASSIGN(_framework, [coder decodeObjectForKey: @"NSFramework"]);
ASSIGN(_connections, (NSMutableArray *)[coder decodeObjectForKey: @"NSConnections"]);
_nextOid = [coder decodeIntForKey: @"NSNextOid"];
{
@ -1287,6 +1302,8 @@ static BOOL _isInInterfaceBuilder = NO;
[self _buildMap: _objects withKeys: objectsKeys andValues: objectsValues];
[self _buildMap: _oids withKeys: oidsKeys andValues: oidsValues];
ASSIGN(_connections, (NSMutableArray *)[coder decodeObjectForKey: @"NSConnections"]);
// instantiate...
_topLevelObjects = [[NSMutableSet alloc] init];
}
@ -1358,6 +1375,16 @@ static BOOL _isInInterfaceBuilder = NO;
{
return _root;
}
- (void) setNextOid: (int)noid
{
_nextOid = noid;
}
- (int) nextOid
{
return _nextOid;
}
@end
@interface NSButtonImageSource : NSObject <NSCoding>

View file

@ -3939,7 +3939,14 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[aCoder encodeInt: vFlags
forKey: @"NSvFlags"];
[aCoder encodeObject: _super_view forKey: @"NSSuperview"];
//
// Don't attempt to archive the superview of a view which is the
// content view for a window.
//
if(([[self window] contentView] != self) && _super_view != nil)
{
[aCoder encodeObject: _super_view forKey: @"NSSuperview"];
}
}
else
{