mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 19:01:15 +00:00
* Source/NSBitmapImageRep.m (-copyWithZone): Changed the call
from -copyWithZone: to -mutableCopyWithZone:. * Tests/gui/NSBitmapImageRep/testcopy.m: Test for this change Patch by Josh Freeman <tedge>. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@38301 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
29f4f8c512
commit
8da8a7add8
4 changed files with 45 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
|||
2015-01-23 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSBitmapImageRep.m (-copyWithZone): Changed the call from
|
||||
-copyWithZone: to -mutableCopyWithZone:.
|
||||
* Tests/gui/NSBitmapImageRep/testcopy.m: Test for this change
|
||||
Patch by Josh Freeman <tedge>.
|
||||
|
||||
2015-01-23 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/tiff.m: Correct check for old libtiff version based on
|
||||
|
|
|
@ -1762,7 +1762,7 @@ _set_bit_value(unsigned char *base, long msb_off, int bit_width,
|
|||
copy = (NSBitmapImageRep*)[super copyWithZone: zone];
|
||||
|
||||
copy->_properties = [_properties copyWithZone: zone];
|
||||
copy->_imageData = [_imageData copyWithZone: zone];
|
||||
copy->_imageData = [_imageData mutableCopyWithZone: zone];
|
||||
copy->_imagePlanes = NSZoneMalloc(zone, sizeof(unsigned char*) * MAX_PLANES);
|
||||
if (_imageData == nil)
|
||||
{
|
||||
|
|
0
Tests/gui/NSBitmapImageRep/TestInfo
Normal file
0
Tests/gui/NSBitmapImageRep/TestInfo
Normal file
37
Tests/gui/NSBitmapImageRep/testcopy.m
Normal file
37
Tests/gui/NSBitmapImageRep/testcopy.m
Normal file
|
@ -0,0 +1,37 @@
|
|||
#import "ObjectTesting.h"
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <AppKit/NSApplication.h>
|
||||
#import <AppKit/NSBitmapImageRep.h>
|
||||
#import <AppKit/NSGraphics.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSBitmapImageRep *origBitmap, *copy1Bitmap, *copy2Bitmap;
|
||||
|
||||
origBitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
|
||||
pixelsWide: 4
|
||||
pixelsHigh: 4
|
||||
bitsPerSample: 8
|
||||
samplesPerPixel: 4
|
||||
hasAlpha: YES
|
||||
isPlanar: NO
|
||||
colorSpaceName: NSCalibratedRGBColorSpace
|
||||
bytesPerRow: 0
|
||||
bitsPerPixel: 0];
|
||||
|
||||
copy1Bitmap = [origBitmap copy];
|
||||
|
||||
// Copying immutable NSData reuses the data pointer instead of allocating new memory, so
|
||||
// copying a bitmap with immutable _imageData causes both bitmaps to point to the same memory;
|
||||
// Writing to either copy's pixels will overwrite both, corrupting the image data
|
||||
|
||||
copy2Bitmap = [copy1Bitmap copy];
|
||||
|
||||
pass([copy1Bitmap bitmapData] != [copy2Bitmap bitmapData],
|
||||
"Copied bitmaps have a different image data pointer - could cause image data corruption.");
|
||||
|
||||
[arp release];
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue