Skip to content

Commit 1a6ab9d

Browse files
committed
ignoring invalid devices instead of removing them from the list
1 parent 9efd1e0 commit 1a6ab9d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

openrgb-plugin/src/main/java/de/lars/openrgbplugin/OutputHandler.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import java.util.ArrayList;
1313
import java.util.Arrays;
14-
import java.util.Iterator;
1514
import java.util.List;
1615

1716
public class OutputHandler implements VirtualOutputListener, PixelStreamReceiver {
@@ -80,20 +79,18 @@ public void updateOpenRgbDevices() {
8079
// clear cached list
8180
cachedDeviceControllers.clear();
8281
// loop through all device ids
83-
for(Iterator<Integer> it = devices.iterator(); it.hasNext();) {
84-
int deviceId = it.next();
82+
for (int deviceId : devices) {
8583
// check if device is valid
86-
if(deviceId < controllerCount) {
84+
if (deviceId < controllerCount) {
8785
// add to cache list
8886
cachedDeviceControllers.add(plugin.getOpenRGB().getControllerData(deviceId));
8987
} else {
9088
// print error message and remove device id from list
9189
OpenRgbPlugin.print(String.format("(%s) Found invalid device ID: %d There are only %d OpenRGB devices (max device ID: %d). Removing device from list.",
92-
getName(), deviceId, controllerCount, controllerCount-1));
90+
getName(), deviceId, controllerCount, controllerCount - 1));
9391
OpenRgbPlugin.getInstance().getInterface().getNotificationManager().addNotification(
94-
new Notification(NotificationType.WARN,"OpenRGB Plugin (" + getName() + ")",
95-
String.format("Invalid device ID: %d. Max device ID is %d. Removing device from list.", deviceId, controllerCount-1)));
96-
it.remove();
92+
new Notification(NotificationType.WARN, "OpenRGB Plugin (" + getName() + ")",
93+
String.format("Invalid device ID: %d. Max device ID is %d. Ignoring device.", deviceId, controllerCount - 1)));
9794
}
9895
}
9996
}

0 commit comments

Comments
 (0)