MonoGame/MonoGame

Window is set to null before UnloadContent on the WindowsDX platform

Opened this issue · 1 comments

Prerequisites

  • I have verified this issue is not present in the develop branch
  • I have searched open and closed issues to ensure it has not already been reported.

MonoGame Version

MonoGame 3.8.1.303

Which MonoGame platform are you using?

MonoGame Windows Desktop Application (mgwindowsdx)

Operating System

Windows

Description

On the DesktopGL platform, it's possible to access the game window during UnloadContent. This makes it possible to save the window size and position for example. The window is only disposed during the Platform.Dispose:

protected override void Dispose(bool disposing)
{
if (_view != null)
{
_view.Dispose();
_view = null;
Joystick.CloseDevices();
Sdl.Quit();
}

On the WindowsDX platform, the Windows is disposed earlier in Platform.Exit:

public override void Exit()
{
if (_window != null)
_window.Dispose();
_window = null;
Window = null;
}

Steps to Reproduce

Access the game window during UnloadContent.

Minimal Example Repo

No response

Expected Behavior

The game window shouldn't be disposed before UnloadContent is done.

Resulting Behavior

The game window position and size can't be accessed.

Files

No response

The game window position and size can't be accessed.... The game window shouldn't be disposed before UnloadContent is done.

UnloadContent() Is the place to dispose any manually allocated resources previously allocated via native Malloccalls.

Why would you expect the window to exist during UnloadContent()?

Store the information at load and modify.