catch exception in resolving window handle collision

This commit is contained in:
Kang Yu 2024-09-21 23:46:37 -07:00
parent c47246cc65
commit a541eb0a6c

View file

@ -1168,6 +1168,20 @@ namespace PersistentWindows.Common
}
private void ResolveWindowHandleCollision(IntPtr hwnd)
{
if (resolveHwndConflict)
{
try
{
ResolveWindowHandleCollisionCore(hwnd);
} catch (Exception ex)
{
Log.Error(ex.ToString());
}
}
}
private void ResolveWindowHandleCollisionCore(IntPtr hwnd)
{
bool found_conflict = false;
string process_name = "";
@ -2924,22 +2938,16 @@ namespace PersistentWindows.Common
IntPtr kid = FindMatchingKilledWindow(hwnd);
if (kid == IntPtr.Zero)
{
if (resolveHwndConflict)
{
try
{
ResolveWindowHandleCollision(hwnd);
} catch (Exception ex)
{
Log.Error(ex.ToString());
}
}
ResolveWindowHandleCollision(hwnd);
}
else
{
InheritKilledWindow(hwnd, kid);
if (hwnd != kid)
{
Log.Error($"Inherit position data from killed window 0x{kid.ToString("X")} for {curDisplayMetrics.Title}");
ResolveWindowHandleCollision(hwnd);
}
else
Log.Error($"Inherit position data from existing window 0x{kid.ToString("X")} for {curDisplayMetrics.Title}");
}