Snapshot for release 2026.10.6.1 (internal 1cbe514)
This commit is contained in:
parent
913a2a00b6
commit
abf9146a5b
93 changed files with 10168 additions and 597 deletions
23
tools/PanelWindowTests/PanelWindowTests.csproj
Normal file
23
tools/PanelWindowTests/PanelWindowTests.csproj
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!--
|
||||
Offline checks for the popped-out panel window destroy backup
|
||||
(src\RynthCore.Engine\UI\PanelDestroyFallback.cs, compiled in): when LayeredWindow.Dispose can't post
|
||||
the self-destroy to a panel, it destroys the window only on its owner thread and only if it is still
|
||||
one of our panel windows; otherwise it leaves it hidden. Never a cross-thread DestroyWindow.
|
||||
No windows are created. Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<RootNamespace>PanelWindowTests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\src\RynthCore.Engine\UI\PanelDestroyFallback.cs" Link="Engine\PanelDestroyFallback.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
48
tools/PanelWindowTests/Program.cs
Normal file
48
tools/PanelWindowTests/Program.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using RynthCore.Engine.UI;
|
||||
|
||||
namespace PanelWindowTests;
|
||||
|
||||
/// <summary>
|
||||
/// The backup path of LayeredWindow.Dispose (PanelDestroyPlan.Choose). Win32 only lets the creating
|
||||
/// thread destroy a window. Idea from Silentkelpie (rynth PR #1); re-implemented here.
|
||||
/// </summary>
|
||||
internal static class Program
|
||||
{
|
||||
private static int _checks, _failed;
|
||||
|
||||
private static int Main()
|
||||
{
|
||||
const uint game = 0x1A2C, avalonia = 0x2B40;
|
||||
|
||||
Check(PanelDestroyPlan.Choose(0, game, ourPanel: false) == PanelDestroyFallback.AlreadyGone,
|
||||
"window gone (no owner thread) -> nothing");
|
||||
Check(PanelDestroyPlan.Choose(0, game, ourPanel: true) == PanelDestroyFallback.AlreadyGone,
|
||||
"window gone even if the class looked like ours -> nothing");
|
||||
|
||||
Check(PanelDestroyPlan.Choose(game, game, ourPanel: true) == PanelDestroyFallback.DestroyHere,
|
||||
"game thread owns it, game thread disposing -> destroy here");
|
||||
Check(PanelDestroyPlan.Choose(avalonia, avalonia, ourPanel: true) == PanelDestroyFallback.DestroyHere,
|
||||
"Avalonia UI thread owns it, Avalonia UI thread disposing -> destroy here");
|
||||
|
||||
Check(PanelDestroyPlan.Choose(avalonia, game, ourPanel: true) == PanelDestroyFallback.LeaveHidden,
|
||||
"panel made on the Avalonia UI thread, disposed from the game thread -> leave hidden, no cross-thread destroy");
|
||||
Check(PanelDestroyPlan.Choose(game, avalonia, ourPanel: true) == PanelDestroyFallback.LeaveHidden,
|
||||
"panel made on the game thread, disposed from the Avalonia UI thread (redock) -> leave hidden");
|
||||
|
||||
Check(PanelDestroyPlan.Choose(game, game, ourPanel: false) == PanelDestroyFallback.AlreadyGone,
|
||||
"handle reused by a window that isn't a panel -> never destroy it");
|
||||
Check(PanelDestroyPlan.Choose(avalonia, game, ourPanel: false) == PanelDestroyFallback.AlreadyGone,
|
||||
"handle reused on another thread -> never touch it");
|
||||
|
||||
Console.WriteLine($"{_checks} check(s), {_failed} failed.");
|
||||
return _failed == 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
private static void Check(bool ok, string what)
|
||||
{
|
||||
_checks++;
|
||||
if (ok) return;
|
||||
_failed++;
|
||||
Console.WriteLine($"[FAIL] {what}");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue