diff --git a/ChangeLog b/ChangeLog index 3700e37aa..82f99dbeb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-09-08 Eric Wasylishen + + * Source/NSImage.m: Throw an exception if you attempt to lock focus on an image with + size (0, 0) + * Source/NSCachedImageRep.m: Throw an exception if you attempt to create a cached + image rep with a size of (0, 0). + 2011-09-07 Eric Wasylishen * Source/NSFontPanel.m: Add a tooltip on the character panel button diff --git a/Source/NSCachedImageRep.m b/Source/NSCachedImageRep.m index 444e51609..6f03301c2 100644 --- a/Source/NSCachedImageRep.m +++ b/Source/NSCachedImageRep.m @@ -89,6 +89,14 @@ { NSWindow *win; + if (aSize.width <= 0 || aSize.height <= 0 || + pixelsWide <= 0 || pixelsHigh <= 0) + { + [NSException raise: NSInvalidArgumentException + format: @"NSCachedImageRep created with size %@ pixelsWide %d pixelsHigh %d", + NSStringFromSize(aSize), pixelsWide, pixelsHigh]; + } + // FIXME: Only create new window when separate is YES win = [[GSCacheW alloc] initWithContentRect: NSMakeRect(0, 0, pixelsWide, pixelsHigh) styleMask: NSBorderlessWindowMask | NSUnscaledWindowMask diff --git a/Source/NSImage.m b/Source/NSImage.m index 33f191fc8..3277f8dd1 100644 --- a/Source/NSImage.m +++ b/Source/NSImage.m @@ -1055,6 +1055,10 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep) NSWindow *window; GSRepData *repd; + if (NSSizesEqual(NSZeroSize, [self size])) + [NSException raise: NSImageCacheException + format: @"Cannot lock focus on image with size (0, 0)"]; + if (imageRep == nil) imageRep = [self bestRepresentationForDevice: nil];