From 5623bf253bcc4b57af8525d586f02aac10645088 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 23 Nov 2025 18:05:12 +0800 Subject: [PATCH] Add null checks and improve dialog window handling Added early null checks for `hwnd` to prevent invalid processing. Enhanced thread safety by locking `_dialogWindow` updates. Documented dialog window state handling with comments for clarity. Handled scenarios for dialog window movement, resizing, hiding, destruction, and termination. Improved robustness and maintainability. --- .../DialogJump/DialogJump.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs b/Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs index 4a3e6474ef2..53df05bf259 100644 --- a/Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs +++ b/Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs @@ -496,6 +496,8 @@ private static async void ForegroundChangeCallback( uint dwmsEventTime ) { + if (hwnd.IsNull) return; + await _foregroundChangeLock.WaitAsync(); try { @@ -647,6 +649,8 @@ private static void LocationChangeCallback( uint dwmsEventTime ) { + if (hwnd.IsNull) return; + // If the dialog window is moved, update the Dialog Jump window position var dialogWindowExist = false; lock (_dialogWindowLock) @@ -672,6 +676,8 @@ private static void MoveSizeCallBack( uint dwmsEventTime ) { + if (hwnd.IsNull) return; + // If the dialog window is moved or resized, update the Dialog Jump window position if (_dragMoveTimer != null) { @@ -697,6 +703,8 @@ private static void DestroyChangeCallback( uint dwmsEventTime ) { + if (hwnd.IsNull) return; + // If the dialog window is destroyed, set _dialogWindowHandle to null var dialogWindowExist = false; lock (_dialogWindowLock) @@ -728,6 +736,8 @@ private static void HideChangeCallback( uint dwmsEventTime ) { + if (hwnd.IsNull) return; + // If the dialog window is hidden, set _dialogWindowHandle to null var dialogWindowExist = false; lock (_dialogWindowLock) @@ -759,6 +769,8 @@ private static void DialogEndChangeCallback( uint dwmsEventTime ) { + if (hwnd.IsNull) return; + // If the dialog window is ended, set _dialogWindowHandle to null var dialogWindowExist = false; lock (_dialogWindowLock)