Browse Source
Merge pull request #3306 from AvaloniaUI/fixes/double-detach-window-issue
Fix Exception when window is closed via Close() Method
pull/3309/head
danwalmsley
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
5 additions and
3 deletions
-
src/Avalonia.Controls/Window.cs
-
tests/Avalonia.Controls.UnitTests/WindowTests.cs
-
tests/Avalonia.UnitTests/MockWindowingPlatform.cs
|
|
|
@ -336,7 +336,6 @@ namespace Avalonia.Controls |
|
|
|
if (close) |
|
|
|
{ |
|
|
|
PlatformImpl?.Dispose(); |
|
|
|
HandleClosed(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -228,8 +228,7 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
{ |
|
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow)) |
|
|
|
{ |
|
|
|
var windowImpl = Mock.Of<IWindowImpl>(x => x.Scaling == 1); |
|
|
|
var target = new Window(windowImpl); |
|
|
|
var target = new Window(); |
|
|
|
|
|
|
|
target.Show(); |
|
|
|
target.Close(); |
|
|
|
|
|
|
|
@ -28,6 +28,10 @@ namespace Avalonia.UnitTests |
|
|
|
return CreatePopupMock().Object; |
|
|
|
|
|
|
|
}); |
|
|
|
mock.Setup(x => x.Dispose()).Callback(() => |
|
|
|
{ |
|
|
|
mock.Object.Closed?.Invoke(); |
|
|
|
}); |
|
|
|
PixelPoint pos = default; |
|
|
|
mock.SetupGet(x => x.Position).Returns(() => pos); |
|
|
|
mock.Setup(x => x.Move(It.IsAny<PixelPoint>())).Callback(new Action<PixelPoint>(np => pos = np)); |
|
|
|
|