Fix NS toolbar image release crash (bug#43973)

The toolbar fails to make a proper copy of EmacsImage objects, so
releasing the copy incorrectly released instance variables from the
original objects.

* src/nsimage.m ([EmacsImage copyWithZone:]): New function to enable
correct copying of EmacsImage.
This commit is contained in:
Alan Third 2021-01-02 18:19:39 +00:00
parent dde3269633
commit d84cf78df8

View file

@ -293,6 +293,18 @@ - (void)dealloc
}
- (id)copyWithZone:(NSZone *)zone
{
EmacsImage *copy = [super copyWithZone:zone];
copy->stippleMask = [stippleMask copyWithZone:zone];
copy->bmRep = [bmRep copyWithZone:zone];
copy->transform = [transform copyWithZone:zone];
return copy;
}
/* Create image from monochrome bitmap. If both FG and BG are 0
(black), set the background to white and make it transparent. */
- (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h