Skip to content

Conversation

@Bananz0
Copy link

@Bananz0 Bananz0 commented Feb 7, 2026

QL issue

I have a laptop with an eGPU and have this issue when the egpu is unplugged and replugged in.

Copilot AI review requested due to automatic review settings February 7, 2026 16:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves resilience of DisplayDeviceHelper.GetMonitorColorProfileFromWindow by handling exceptions that can occur during display reconfiguration scenarios (e.g., eGPU disconnect/reconnect), preventing crashes and returning null instead.

Changes:

  • Wrap GetMonitorColorProfileFromWindow logic in a try/catch.
  • Add a specific COMException filter for 0x80263001 (desktop composition disabled) with a targeted log message.
  • Add a general exception handler that logs and returns null.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +85 to +89
catch (COMException ex) when (ex.HResult == unchecked((int)0x80263001))
{
// Desktop composition is disabled (e.g., during eGPU reconnection)
ProcessHelper.WriteLog("Failed to get color profile: Desktop composition is disabled. This is expected during display reconfiguration.");
return null;
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HRESULT check uses a magic number and ex.HResult. For readability and to make the intent explicit (DWM_E_COMPOSITIONDISABLED = 0x80263001), consider introducing a named constant (or enum) and using COMException.ErrorCode in the filter instead of HResult.

Copilot uses AI. Check for mistakes.
return GetMonitorColorProfile(hMonitor);
try
{
var hMonitor = MonitorFromWindow(new WindowInteropHelper(window).EnsureHandle(), MonitorDefaults.TONEAREST);
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace this call with a call to managed code if possible.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant