Skip to content

Commit

Permalink
fix infinite cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimecbernardo committed Jul 13, 2022
1 parent 4f8463a commit bb96db5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/modules/fancyzones/FancyZonesLib/MonitorUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ namespace MonitorUtils
std::vector<FancyZonesDataTypes::MonitorId> GetDisplays()
{
auto allMonitors = FancyZonesUtils::GetAllMonitorInfo<&MONITORINFOEX::rcWork>();
std::unordered_map<std::wstring, DWORD> displayDeviceIdxMap;
std::vector<FancyZonesDataTypes::MonitorId> result{};

for (auto& monitorData : allMonitors)
Expand All @@ -237,7 +236,9 @@ namespace MonitorUtils

bool foundActiveMonitor = false;

while(EnumDisplayDevicesW(monitorInfo.szDevice, displayDeviceIdxMap[monitorInfo.szDevice], &displayDevice, EDD_GET_DEVICE_INTERFACE_NAME))
DWORD displayDeviceIndex = 0;

while (EnumDisplayDevicesW(monitorInfo.szDevice, displayDeviceIndex, &displayDevice, EDD_GET_DEVICE_INTERFACE_NAME))
{
Logger::info(L"Get display device for display {} : {}", monitorInfo.szDevice, displayDevice.DeviceID);
if (WI_IsFlagSet(displayDevice.StateFlags, DISPLAY_DEVICE_ACTIVE) &&
Expand All @@ -247,6 +248,7 @@ namespace MonitorUtils
foundActiveMonitor = true;
break;
}
displayDeviceIndex++;
}

if (foundActiveMonitor)
Expand Down

0 comments on commit bb96db5

Please sign in to comment.