mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 18:21:22 +00:00
When we allocate objects in a given zone, we are not guaranteed to get back something actually allocated in that zone (eg the runtime might use a common heap) so if we are creating/destroying other heap memory based on zone we need to make sure we are consistently using the same zone info.
This commit is contained in:
parent
87e132ca82
commit
f7fd33a746
1 changed files with 29 additions and 11 deletions
|
@ -287,17 +287,21 @@ static CGFloat default_miter_limit = 10.0;
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (_pathElements != NULL)
|
||||
if (_pathElements)
|
||||
{
|
||||
GSIArrayEmpty(_pathElements);
|
||||
NSZoneFree([self zone], _pathElements);
|
||||
}
|
||||
|
||||
if (_cacheImage != nil)
|
||||
RELEASE(_cacheImage);
|
||||
if (_cacheImage)
|
||||
{
|
||||
RELEASE(_cacheImage);
|
||||
}
|
||||
|
||||
if (_dash_pattern != NULL)
|
||||
NSZoneFree([self zone], _dash_pattern);
|
||||
if (_dash_pattern)
|
||||
{
|
||||
NSZoneFree([self zone], _dash_pattern);
|
||||
}
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -2069,22 +2073,36 @@ static int winding_curve(double_point from, double_point to, double_point c1,
|
|||
//
|
||||
// NSCopying Protocol
|
||||
//
|
||||
- (id)copyWithZone:(NSZone *)zone
|
||||
- (id) copyWithZone: (NSZone *)zone
|
||||
{
|
||||
NSBezierPath *path = (NSBezierPath*)NSCopyObject (self, 0, zone);
|
||||
NSBezierPath *path = (NSBezierPath*)NSCopyObject(self, 0, zone);
|
||||
|
||||
/* Get the zone actually usd by the copy so we can use it consistently.
|
||||
*/
|
||||
zone = [path zone];
|
||||
|
||||
if (_cachesBezierPath && _cacheImage)
|
||||
path->_cacheImage = [_cacheImage copy];
|
||||
{
|
||||
// FIXME ... should this retain rather than copy?
|
||||
path->_cacheImage = [_cacheImage copyWithZone: zone];
|
||||
}
|
||||
else
|
||||
{
|
||||
path->_cacheImage = nil;
|
||||
}
|
||||
|
||||
if (_dash_pattern != NULL)
|
||||
if (_dash_pattern)
|
||||
{
|
||||
CGFloat *pattern = NSZoneMalloc(zone, _dash_count * sizeof(CGFloat));
|
||||
|
||||
memcpy(pattern, _dash_pattern, _dash_count * sizeof(CGFloat));
|
||||
_dash_pattern = pattern;
|
||||
path->_dash_pattern = pattern;
|
||||
}
|
||||
|
||||
path->_pathElements = GSIArrayCopyWithZone(_pathElements, zone);
|
||||
if (_pathElements)
|
||||
{
|
||||
path->_pathElements = GSIArrayCopyWithZone(_pathElements, zone);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue