Skip to content

Commit 5623bf2

Browse files
committed
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.
1 parent 38c0fae commit 5623bf2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ private static async void ForegroundChangeCallback(
496496
uint dwmsEventTime
497497
)
498498
{
499+
if (hwnd.IsNull) return;
500+
499501
await _foregroundChangeLock.WaitAsync();
500502
try
501503
{
@@ -647,6 +649,8 @@ private static void LocationChangeCallback(
647649
uint dwmsEventTime
648650
)
649651
{
652+
if (hwnd.IsNull) return;
653+
650654
// If the dialog window is moved, update the Dialog Jump window position
651655
var dialogWindowExist = false;
652656
lock (_dialogWindowLock)
@@ -672,6 +676,8 @@ private static void MoveSizeCallBack(
672676
uint dwmsEventTime
673677
)
674678
{
679+
if (hwnd.IsNull) return;
680+
675681
// If the dialog window is moved or resized, update the Dialog Jump window position
676682
if (_dragMoveTimer != null)
677683
{
@@ -697,6 +703,8 @@ private static void DestroyChangeCallback(
697703
uint dwmsEventTime
698704
)
699705
{
706+
if (hwnd.IsNull) return;
707+
700708
// If the dialog window is destroyed, set _dialogWindowHandle to null
701709
var dialogWindowExist = false;
702710
lock (_dialogWindowLock)
@@ -728,6 +736,8 @@ private static void HideChangeCallback(
728736
uint dwmsEventTime
729737
)
730738
{
739+
if (hwnd.IsNull) return;
740+
731741
// If the dialog window is hidden, set _dialogWindowHandle to null
732742
var dialogWindowExist = false;
733743
lock (_dialogWindowLock)
@@ -759,6 +769,8 @@ private static void DialogEndChangeCallback(
759769
uint dwmsEventTime
760770
)
761771
{
772+
if (hwnd.IsNull) return;
773+
762774
// If the dialog window is ended, set _dialogWindowHandle to null
763775
var dialogWindowExist = false;
764776
lock (_dialogWindowLock)

0 commit comments

Comments
 (0)