Pārlūkot izejas kodu

Win32: Minor changes to disabled cursor fix over RDP

- Use _glfw_calloc and _glfw_free
- Exit from _glfwInitWin32 with error if we fail to create a blank cursor on a remote session
Doug Binks 1 gadu atpakaļ
vecāks
revīzija
d79afa8055
1 mainītis faili ar 10 papildinājumiem un 4 dzēšanām
  1. 10 4
      src/win32_init.c

+ 10 - 4
src/win32_init.c

@@ -438,8 +438,8 @@ static void createBlankCursor(void)
     //       using SetCursorPos when connected over RDP
     int cursorWidth = GetSystemMetrics(SM_CXCURSOR);
     int cursorHeight = GetSystemMetrics(SM_CYCURSOR);
-    unsigned char* andMask = calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char));
-    unsigned char* xorMask = calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char));
+    unsigned char* andMask = _glfw_calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char));
+    unsigned char* xorMask = _glfw_calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char));
 
     if (andMask != NULL && xorMask != NULL) {
 
@@ -449,8 +449,8 @@ static void createBlankCursor(void)
         // which serves as an acceptable fallback blank cursor (other than on RDP)
         _glfw.win32.blankCursor = CreateCursor(NULL, 0, 0, cursorWidth, cursorHeight, andMask, xorMask);
 
-        free(andMask);
-        free(xorMask);
+        _glfw_free(andMask);
+        _glfw_free(xorMask);
     }
 }
 
@@ -740,6 +740,12 @@ int _glfwInitWin32(void)
 
     //Some hacks are needed to support Remote Desktop...
     initRemoteSession();
+    if (_glfw.win32.isRemoteSession && _glfw.win32.blankCursor == NULL )
+    {
+        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+                             "Win32: Failed to create blank cursor for remote session.");
+        return GLFW_FALSE;
+    }
 
     _glfwPollMonitorsWin32();
     return GLFW_TRUE;