Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win32 Window doesn't unregister class #393

Open
Hilarius86 opened this issue Jun 12, 2023 · 5 comments
Open

Win32 Window doesn't unregister class #393

Hilarius86 opened this issue Jun 12, 2023 · 5 comments

Comments

@Hilarius86
Copy link
Contributor

When creating a window for the DirectX 11 Rendersystem a WindowClass is registered. That window class is not unregistered. In 2.1 that was silently ignored and a window was created anyway, but now (2.2 for me) it fails and throws an exception.

ogre-next\RenderSystems\Direct3D11\src\Windowing\WIN32\OgreD3D11WindowHwnd.cpp

if (!mClassRegistered
{
if (!RegisterClassEx(&wcex))
{
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"RegisterClassEx failed! Cannot create window",
"D3D11WindowHwnd::create");
}
mClassRegistered = true;
}

Shouldn't this class unregister it`s window class in the destroy function ala?

if( mClassRegistered )
{
UnregisterClass( OGRE_D3D11_WIN_CLASS_NAME, 0 );
mClassRegistered = false;
}

@darksylinc
Copy link
Member

Hi!

The block is protected by a static global variable:

if( !mClassRegistered )
{
	mClassRegistered = true;
}

How are you able to enter that block twice?

@Hilarius86
Copy link
Contributor Author

I have to look for it a little more.
Working theory is about unloading the Ogre Dlls. RenderSystems are Plugins and loaded/unloaded with the Ogre Root, which I shut down in between.

@Hilarius86
Copy link
Contributor Author

It works as described. When shutting down the 3D rendering part of the application OgreRoot is deleted. That unloads all plugins and therefore the dll. When restarting 3D, the Dll is loaded again and a new set of statics is generated / initalised. But the registration of the windowclass is still active.

@Hilarius86
Copy link
Contributor Author

@darksylinc Do you care for me to provide a PR for this? Finishing up on updateing to 2.2 and remembered this issue.

@darksylinc
Copy link
Member

Sure!!!

PRs are more than welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants