From c33edac4b41d708759778ad4c6a5fd362f3fac41 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Sat, 17 Feb 2024 18:29:32 +0100 Subject: [PATCH] Better error handling for missing display name https://github.com/seerge/g-helper/issues/2077 --- app/Display/ScreenInterrogatory.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/Display/ScreenInterrogatory.cs b/app/Display/ScreenInterrogatory.cs index 1840b27b..c285b354 100644 --- a/app/Display/ScreenInterrogatory.cs +++ b/app/Display/ScreenInterrogatory.cs @@ -339,7 +339,20 @@ namespace GHelper.Display for (var i = 0; i < modeCount; i++) if (displayModes[i].infoType == DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_TARGET) - yield return DeviceName(displayModes[i].adapterId, displayModes[i].id); + { + DISPLAYCONFIG_TARGET_DEVICE_NAME? displayName = null; + try + { + displayName = DeviceName(displayModes[i].adapterId, displayModes[i].id); + + } catch (Exception e) + { + Logger.WriteLine(e.Message); + } + + if (displayName is not null) yield return (DISPLAYCONFIG_TARGET_DEVICE_NAME)displayName; + } + }