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.
This commit is contained in:
Jack251970 2025-11-23 18:05:12 +08:00
parent 38c0fae064
commit 5623bf253b

View file

@ -496,6 +496,8 @@ namespace Flow.Launcher.Infrastructure.DialogJump
uint dwmsEventTime
)
{
if (hwnd.IsNull) return;
await _foregroundChangeLock.WaitAsync();
try
{
@ -647,6 +649,8 @@ namespace Flow.Launcher.Infrastructure.DialogJump
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 @@ namespace Flow.Launcher.Infrastructure.DialogJump
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 @@ namespace Flow.Launcher.Infrastructure.DialogJump
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 @@ namespace Flow.Launcher.Infrastructure.DialogJump
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 @@ namespace Flow.Launcher.Infrastructure.DialogJump
uint dwmsEventTime
)
{
if (hwnd.IsNull) return;
// If the dialog window is ended, set _dialogWindowHandle to null
var dialogWindowExist = false;
lock (_dialogWindowLock)