Browse Source

Merge pull request #10974 from AvaloniaUI/fixes/prevent-double-close

Make sure that HandleClosed is called only once
pull/10982/head
Nikita Tsukanov 4 years ago
committed by GitHub
parent
commit
fbc2dde020
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      src/Avalonia.Controls/Primitives/PopupRoot.cs
  2. 2
      src/Avalonia.Controls/TopLevel.cs
  3. 1
      src/Avalonia.X11/X11Window.cs
  4. 1
      src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs

1
src/Avalonia.Controls/Primitives/PopupRoot.cs

@ -90,7 +90,6 @@ namespace Avalonia.Controls.Primitives
public void Dispose() public void Dispose()
{ {
PlatformImpl?.Dispose(); PlatformImpl?.Dispose();
HandleClosed();
} }
private void UpdatePosition() private void UpdatePosition()

2
src/Avalonia.Controls/TopLevel.cs

@ -1,5 +1,6 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using Avalonia.Reactive; using Avalonia.Reactive;
using Avalonia.Controls.Metadata; using Avalonia.Controls.Metadata;
using Avalonia.Controls.Platform; using Avalonia.Controls.Platform;
@ -531,6 +532,7 @@ namespace Avalonia.Controls
// We need to wait for the renderer to complete any in-flight operations // We need to wait for the renderer to complete any in-flight operations
Renderer.Dispose(); Renderer.Dispose();
Debug.Assert(PlatformImpl != null);
// The PlatformImpl is completely invalid at this point // The PlatformImpl is completely invalid at this point
PlatformImpl = null; PlatformImpl = null;

1
src/Avalonia.X11/X11Window.cs

@ -898,7 +898,6 @@ namespace Avalonia.X11
_platform.XI2?.OnWindowDestroyed(_handle); _platform.XI2?.OnWindowDestroyed(_handle);
var handle = _handle; var handle = _handle;
_handle = IntPtr.Zero; _handle = IntPtr.Zero;
Closed?.Invoke();
_mouse.Dispose(); _mouse.Dispose();
_touch.Dispose(); _touch.Dispose();
if (!fromDestroyNotification) if (!fromDestroyNotification)

1
src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs

@ -115,7 +115,6 @@ namespace Avalonia.Win32
_hwnd = IntPtr.Zero; _hwnd = IntPtr.Zero;
//Remove root reference to this class, so unmanaged delegate can be collected //Remove root reference to this class, so unmanaged delegate can be collected
s_instances.Remove(this); s_instances.Remove(this);
Closed?.Invoke();
_mouseDevice.Dispose(); _mouseDevice.Dispose();
_touchDevice.Dispose(); _touchDevice.Dispose();

Loading…
Cancel
Save