Fix memory leaks changing custom native cursors on macOS

This commit is contained in:
David Capello 2017-01-10 11:10:06 -03:00
parent 8691345f03
commit 0b37d23c37

View File

@ -187,6 +187,7 @@ using namespace she;
}
}
@autoreleasepool {
CGDataProviderRef dataRef =
CGDataProviderCreateWithData(nullptr, &buf[0],
w*h*4, nullptr);
@ -206,18 +207,19 @@ using namespace she;
NSCursor* nsCursor = nullptr;
if (img) {
NSImage* image =
[[NSImage new] initWithCGImage:img
[[NSImage alloc] initWithCGImage:img
size:NSMakeSize(w, h)];
CGImageRelease(img);
nsCursor =
[[NSCursor new] initWithImage:image
[[NSCursor alloc] initWithImage:image
hotSpot:NSMakePoint(scale*focus.x + scale/2,
scale*focus.y + scale/2)];
}
if (nsCursor)
[self.contentView setCursor:nsCursor];
return (nsCursor ? YES: NO);
}
}
- (void)noResponderFor:(SEL)eventSelector