diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index d0112d26..8891f8a6 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -338,7 +338,8 @@ void _glfwPollMonitorsNS(void) // display replacement on machines with automatic graphics // switching const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]); - for (uint32_t j = 0; j < disconnectedCount; j++) + uint32_t j; + for (j = 0; j < disconnectedCount; j++) { if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber) { @@ -347,6 +348,9 @@ void _glfwPollMonitorsNS(void) } } + if (j < disconnectedCount) + continue; + const CGSize size = CGDisplayScreenSize(displays[i]); char* name = getDisplayName(displays[i]); if (!name)