From 10e26bdc3a75dcac1e1ec638669e71aaf1300242 Mon Sep 17 00:00:00 2001 From: Curtis Wensley Date: Mon, 31 Jan 2022 14:00:09 -0800 Subject: [PATCH] Wpf: Fix crash when closing a Dialog --- src/Eto.Wpf/Forms/FormHandler.cs | 7 +++++++ src/Eto.Wpf/Forms/WpfWindow.cs | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Eto.Wpf/Forms/FormHandler.cs b/src/Eto.Wpf/Forms/FormHandler.cs index df0df493f1..649df0fee3 100644 --- a/src/Eto.Wpf/Forms/FormHandler.cs +++ b/src/Eto.Wpf/Forms/FormHandler.cs @@ -56,6 +56,13 @@ public virtual void Show() WpfFrameworkElementHelper.ShouldCaptureMouse = false; } + protected override void InternalClose() + { + // Clear owner so WPF doesn't change the z-order of the parent when closing + SetOwner(null); + Control.Close(); + } + public bool ShowActivated { get { return Control.ShowActivated; } diff --git a/src/Eto.Wpf/Forms/WpfWindow.cs b/src/Eto.Wpf/Forms/WpfWindow.cs index 524cb2c5a3..257dbbd266 100644 --- a/src/Eto.Wpf/Forms/WpfWindow.cs +++ b/src/Eto.Wpf/Forms/WpfWindow.cs @@ -400,6 +400,8 @@ public Eto.Forms.ToolBar ToolBar toolBarHolder.Content = toolBar != null ? toolBar.ControlObject : null; } } + + protected virtual void InternalClose() => Control.Close(); public void Close() { @@ -408,9 +410,7 @@ public void Close() // prevent crash if we call this more than once.. if (!IsClosing) { - // Clear owner so WPF doesn't change the z-order of the parent when closing - SetOwner(null); - Control.Close(); + InternalClose(); } } else