Update behavior of initWithBitmapDataPlanes:... to match documentation and return nil if it cannot initialize given the existing data

This commit is contained in:
Gregory John Casamento 2021-10-12 19:20:24 -04:00
parent 2214368e53
commit 19426c573d
2 changed files with 10 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2021-10-12 Gregory John Casamento <greg.casamento@gmail.com>
* Source/NSBitmapImageRep.m: Change initWithBitmapDataPlanes:...
to conform to Apple documented behavior and return nil if it
cannot initialize with the given arguments.
2021-10-03 Gregory John Casamento <greg.casamento@gmail.com>
* Headers/AppKit/NSComboBox.h: Add check to see if @optional

View file

@ -439,10 +439,11 @@
{
NSDebugLLog(@"NSImage", @"Creating bitmap image with pw %d ph %d bps %d spp %d alpha %d, planar %d cs %@",
(int)width,(int) height, (int)bps, (int)spp, alpha, isPlanar, colorSpaceName);
if (!bps || !spp || !width || !height)
if (!bps || !spp || !width || !height)
{
[NSException raise: NSInvalidArgumentException
format: @"Required arguments not specified creating NSBitmapImageRep"];
// Per Apple documentation, return nil if can't initialize.
NSLog(@"Cannot initialize image with bps = %ld, spp = %ld, width = %ld, height = %ld", bps, spp, width, height);
return nil;
}
_pixelsWide = width;