Fix potential crash when changing cursor - don't release the NSCursor object if it's already been released

This commit is contained in:
Jonny Paton 2021-01-06 23:25:57 +00:00 committed by Lukas Dürrenberger
parent 9541719893
commit f4844c11f8

View File

@ -71,7 +71,11 @@ CursorImpl::~CursorImpl()
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot) bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot)
{ {
[m_cursor release]; if (m_cursor)
{
[m_cursor release];
m_cursor = nil;
}
NSSize nssize = NSMakeSize(size.x, size.y); NSSize nssize = NSMakeSize(size.x, size.y);
NSImage* image = [NSImage imageWithRawData:pixels andSize:nssize]; NSImage* image = [NSImage imageWithRawData:pixels andSize:nssize];
@ -85,7 +89,11 @@ bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hot
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool CursorImpl::loadFromSystem(Cursor::Type type) bool CursorImpl::loadFromSystem(Cursor::Type type)
{ {
[m_cursor release]; if (m_cursor)
{
[m_cursor release];
m_cursor = nil;
}
switch (type) switch (type)
{ {