mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-10 20:45:38 +02:00
fix dead-loop in TrimQueue(), causing auto-restore to hang, possibly due to wrong inheritance
This commit is contained in:
parent
0adf762fa0
commit
62452f3e0b
1 changed files with 27 additions and 4 deletions
|
@ -2216,13 +2216,36 @@ namespace PersistentWindows.Common
|
||||||
{
|
{
|
||||||
while (monitorApplications[displayKey][hwnd].Count > MaxHistoryQueueLength)
|
while (monitorApplications[displayKey][hwnd].Count > MaxHistoryQueueLength)
|
||||||
{
|
{
|
||||||
// limit length of capture history
|
// limit length of snapshot capture history
|
||||||
|
ulong acc_flags = 0;
|
||||||
|
for (int i = monitorApplications[displayKey][hwnd].Count - 1; i >= 0; --i)
|
||||||
|
{
|
||||||
|
ulong snapshot_flags = monitorApplications[displayKey][hwnd][i].SnapShotFlags;
|
||||||
|
if (snapshot_flags != 0)
|
||||||
|
{
|
||||||
|
if ((snapshot_flags | acc_flags) == acc_flags)
|
||||||
|
{
|
||||||
|
Log.Event($"trim redundant snapshot record for {windowTitle[hwnd]}");
|
||||||
|
monitorApplications[displayKey][hwnd].RemoveAt(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
acc_flags |= snapshot_flags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (monitorApplications[displayKey][hwnd].Count > MaxHistoryQueueLength)
|
||||||
|
{
|
||||||
|
// limit length of non-snapshot capture history
|
||||||
for (int i = 0; i < monitorApplications[displayKey][hwnd].Count; ++i)
|
for (int i = 0; i < monitorApplications[displayKey][hwnd].Count; ++i)
|
||||||
{
|
{
|
||||||
if (monitorApplications[displayKey][hwnd][i].SnapShotFlags != 0)
|
ulong snapshot_flags = monitorApplications[displayKey][hwnd][i].SnapShotFlags;
|
||||||
continue; //preserve snapshot record
|
if (snapshot_flags != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Log.Event($"trim regular record for {windowTitle[hwnd]}");
|
||||||
monitorApplications[displayKey][hwnd].RemoveAt(i);
|
monitorApplications[displayKey][hwnd].RemoveAt(i);
|
||||||
break; //remove one record at one time
|
break; //remove one record in each iteration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue