From f4844c11f88e197d846a5f819ba952a41b5d34e5 Mon Sep 17 00:00:00 2001 From: Jonny Paton Date: Wed, 6 Jan 2021 23:25:57 +0000 Subject: [PATCH] Fix potential crash when changing cursor - don't release the NSCursor object if it's already been released --- src/SFML/Window/OSX/CursorImpl.mm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/SFML/Window/OSX/CursorImpl.mm b/src/SFML/Window/OSX/CursorImpl.mm index cf87b025b..4d90245e0 100644 --- a/src/SFML/Window/OSX/CursorImpl.mm +++ b/src/SFML/Window/OSX/CursorImpl.mm @@ -71,7 +71,11 @@ CursorImpl::~CursorImpl() //////////////////////////////////////////////////////////// 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); 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) { - [m_cursor release]; + if (m_cursor) + { + [m_cursor release]; + m_cursor = nil; + } switch (type) {