Fixes to keep app running when given illegal view size.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4919 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-09-20 19:00:46 +00:00
parent 5296afaafe
commit 1c21a9c09a
2 changed files with 68 additions and 5 deletions

View file

@ -1,3 +1,11 @@
Mon Sep 20 1999 Nicola Pero <n.pero@mi.flashnet.it>
* Source/NSView.m ([-setFrameSize:]): use zero width or height if
the width or height of the argument is negative, but don't crash
the app. ([-setFrame:]): idem.
Modified by RFM to apply to all other cases of checking view size
also, retain NSAssert() to give core dump wieh built for debugging.
Mon Sep 20 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSPanel.m: Remove unnecessary -center messages.

View file

@ -192,7 +192,16 @@ GSSetDragTypes(NSView* obj, NSArray *types)
NSAssert(frameRect.size.width >= 0 && frameRect.size.height >= 0,
@"illegal frame dimensions supplied");
if (frameRect.size.width < 0)
{
NSLog(@"[NSView -initWithFrame:] given negative width");
frameRect.size.width = 0;
}
if (frameRect.size.height < 0)
{
NSLog(@"[NSView -initWithFrame:] given negative height");
frameRect.size.height = 0;
}
frame = frameRect; // Set frame rectangle
bounds.origin = NSZeroPoint; // Set bounds rectangle
bounds.size = frame.size;
@ -539,7 +548,16 @@ GSSetDragTypes(NSView* obj, NSArray *types)
NSAssert(frameRect.size.width >= 0 && frameRect.size.height >= 0,
@"illegal frame dimensions supplied");
if (frameRect.size.width < 0)
{
NSLog(@"[NSView -setFrame:] given negative width");
frameRect.size.width = 0;
}
if (frameRect.size.height < 0)
{
NSLog(@"[NSView -setFrame:] given negative heigth");
frameRect.size.height = 0;
}
if (coordinates_valid)
(*invalidateImp)(self, invalidateSel);
frame = frameRect;
@ -572,6 +590,16 @@ GSSetDragTypes(NSView* obj, NSArray *types)
NSAssert(newSize.width >= 0 && newSize.height >= 0,
@"illegal frame dimensions supplied");
if (newSize.width < 0)
{
NSLog(@"[NSView -setFrameSize:] given negative width");
newSize.width = 0;
}
if (newSize.height < 0)
{
NSLog(@"[NSView -setFrameSize:] given negative height");
newSize.height = 0;
}
if (coordinates_valid)
(*invalidateImp)(self, invalidateSel);
frame.size = bounds.size = newSize;
@ -622,7 +650,16 @@ GSSetDragTypes(NSView* obj, NSArray *types)
float sy;
NSAssert(newSize.width > 0 && newSize.height > 0, @"illegal size supplied");
if (newSize.width < 0)
{
NSLog(@"[NSView -scaleUnitSquareToSize:] given negative width");
newSize.width = 0;
}
if (newSize.height < 0)
{
NSLog(@"[NSView -scaleUnitSquareToSize:] given negative height");
newSize.height = 0;
}
if (coordinates_valid)
(*invalidateImp)(self, invalidateSel);
@ -669,7 +706,16 @@ GSSetDragTypes(NSView* obj, NSArray *types)
NSAssert(aRect.size.width >= 0 && aRect.size.height >= 0,
@"illegal bounds dimensions supplied");
if (aRect.size.width < 0)
{
NSLog(@"[NSView -setBounds:] given negative width");
aRect.size.width = 0;
}
if (aRect.size.height < 0)
{
NSLog(@"[NSView -setBounds:] given negative height");
aRect.size.height = 0;
}
if (coordinates_valid)
(*invalidateImp)(self, invalidateSel);
@ -731,7 +777,16 @@ GSSetDragTypes(NSView* obj, NSArray *types)
NSAssert(newSize.width >= 0 && newSize.height >= 0,
@"illegal bounds dimensions supplied");
if (newSize.width < 0)
{
NSLog(@"[NSView -setBoundsSize:] given negative width");
newSize.width = 0;
}
if (newSize.height < 0)
{
NSLog(@"[NSView -setBoundsSize:] given negative height");
newSize.height = 0;
}
if (coordinates_valid)
{
(*invalidateImp)(self, invalidateSel);