Skip to content

Commit

Permalink
Merge pull request #2132 from cwensley/curtis/wpf-fix-dialog-owner-crash
Browse files Browse the repository at this point in the history
Wpf: Fix crash when closing a Dialog
  • Loading branch information
cwensley committed Jan 31, 2022
2 parents 5fe2ade + 10e26bd commit 0efdb4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/Eto.Wpf/Forms/FormHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
6 changes: 3 additions & 3 deletions src/Eto.Wpf/Forms/WpfWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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
Expand Down

0 comments on commit 0efdb4b

Please sign in to comment.