From 37a137559eda62d350067c8864f30a2ab51bc630 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 18 Apr 2013 15:30:28 +0200 Subject: [PATCH] Monitor enumeration cleanup. --- src/init.c | 2 +- src/win32_monitor.c | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/init.c b/src/init.c index dbed3c5a..7a990e4a 100644 --- a/src/init.c +++ b/src/init.c @@ -131,7 +131,7 @@ GLFWAPI int glfwInit(void) } _glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount); - if (!_glfw.monitors) + if (_glfw.monitors == NULL || _glfw.monitorCount == 0) { _glfwErrorCallback(GLFW_PLATFORM_ERROR, "No monitors found"); _glfwPlatformTerminate(); diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 605c2acf..dbdd09d1 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -106,8 +106,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) for (;;) { - // Enumerate display adapters - DISPLAY_DEVICE adapter, display; char* name; HDC dc; @@ -148,7 +146,9 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) name = _glfwCreateUTF8FromWideString(display.DeviceString); if (!name) { - // TODO: wat + _glfwDestroyMonitors(monitors, found); + _glfwInputError(GLFW_PLATFORM_ERROR, + "Failed to convert string to UTF-8"); return NULL; } @@ -159,12 +159,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) free(name); DeleteDC(dc); - if (!monitors[found]) - { - // TODO: wat - return NULL; - } - wcscpy(monitors[found]->win32.name, adapter.DeviceName); found++; }