From 7b2540517b09647a7f58dcfa8297b6c5e3e31c6f Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Sat, 21 Jan 2023 16:07:35 +0300 Subject: [PATCH] fix Main Thread Checker warnings on Apple platforms --- client/gui/CursorHandler.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client/gui/CursorHandler.cpp b/client/gui/CursorHandler.cpp index 0e660b7d6..39c19b860 100644 --- a/client/gui/CursorHandler.cpp +++ b/client/gui/CursorHandler.cpp @@ -16,6 +16,10 @@ #include "CAnimation.h" #include "../../lib/CConfigHandler.h" +#ifdef VCMI_APPLE +#include +#endif + std::unique_ptr CursorHandler::createCursor() { if (settings["video"]["cursor"].String() == "auto") @@ -401,10 +405,16 @@ CursorHardware::~CursorHardware() void CursorHardware::setVisible(bool on) { +#ifdef VCMI_APPLE + dispatch_async(dispatch_get_main_queue(), ^{ +#endif if (on) SDL_ShowCursor(SDL_ENABLE); else SDL_ShowCursor(SDL_DISABLE); +#ifdef VCMI_APPLE + }); +#endif } void CursorHardware::setImage(std::shared_ptr image, const Point & pivotOffset) @@ -422,10 +432,16 @@ void CursorHardware::setImage(std::shared_ptr image, const Point & pivot logGlobal->error("Failed to set cursor! SDL says %s", SDL_GetError()); SDL_FreeSurface(cursorSurface); +#ifdef VCMI_APPLE + dispatch_async(dispatch_get_main_queue(), ^{ +#endif SDL_SetCursor(cursor); if (oldCursor) SDL_FreeCursor(oldCursor); +#ifdef VCMI_APPLE + }); +#endif } void CursorHardware::setCursorPosition( const Point & newPos )