From 09b5eef6174f727cb84c7c70e956939636c43a45 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Fri, 22 Feb 2013 14:42:36 +0000 Subject: [PATCH] Fixed: [CPBox setContentView:nil] crash. This is allowed in Cocoa so should not crash Cappuccino either. --- AppKit/CPBox.j | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/AppKit/CPBox.j b/AppKit/CPBox.j index c6a249e3d..c3f39b0f6 100644 --- a/AppKit/CPBox.j +++ b/AppKit/CPBox.j @@ -287,7 +287,14 @@ CPBelowBottom = 6; [aView setFrame:CGRectInset([self bounds], contentMargin.width + borderWidth, contentMargin.height + borderWidth)]; [aView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; - [self replaceSubview:_contentView with:aView]; + + // A nil contentView is allowed (tested in Cocoa 2013-02-22). + if (!aView) + [_contentView removeFromSuperview]; + else if (_contentView) + [self replaceSubview:_contentView with:aView]; + else + [self addSubview:aView]; _contentView = aView; }