Skip to content

Commit

Permalink
fix: Do not destroy the singleton Window for single-window targets
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Oct 2, 2024
1 parent 6b89a0a commit 334c910
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public virtual void Initialize()

public virtual void Activate()
{
if (_isClosed)
if (NativeWindowFactory.SupportsMultipleWindows && _isClosed)
{
throw new InvalidOperationException("Cannot reactivate a closed window.");
}
Expand Down Expand Up @@ -318,10 +318,18 @@ public bool Close()

// Window.PrepareToClose();

// set these to null before marking window as closed as they fail if called after m_bIsClosed is set
// because they check if window is closed already
Window.SetTitleBar(null);
Window.Content = null;
if (NativeWindowFactory.SupportsMultipleWindows)
{
// set these to null before marking window as closed as they fail if called after m_bIsClosed is set
// because they check if window is closed already
Window.SetTitleBar(null);
Window.Content = null;
}
else
{
// Just reset the window to not shown state so it can be reactivated
_wasShown = false;
}

// _windowChrome.SetDesktopWindow(null);

Expand All @@ -336,8 +344,11 @@ public bool Close()
RaiseWindowVisibilityChangedEvent(false);
}

// Close native window, cleanup, and unregister from hwnd mapping from DXamlCore
Shutdown();
if (NativeWindowFactory.SupportsMultipleWindows)
{
// Close native window, cleanup, and unregister from hwnd mapping from DXamlCore
Shutdown();
}

return true;
}
Expand Down

0 comments on commit 334c910

Please sign in to comment.