Fix: GPU Tests on Windows
Use RAII for `GHOST_WindowClass`. For the main Blender executable, only one `GHOST_System` is ever created. But when running tests, this can happen multiple times (eg, GPUOpenGLTest and GPUOpenGLWorkaroundsTest). This results in `GHOST_SystemWin32` trying to register `GHOST_WindowClass` multiple times, so `RegisterClassW` fails with `ERROR_CLASS_ALREADY_EXISTS`. Pull Request: https://projects.blender.org/blender/blender/pulls/144231
This commit is contained in:
@@ -293,6 +293,9 @@ GHOST_TSuccess GHOST_System::init()
|
||||
|
||||
GHOST_TSuccess GHOST_System::exit()
|
||||
{
|
||||
/** WARNING: exit() may run more than once, since it may need to be called from a derived class
|
||||
* destructor. Take it into account when modifying this function. */
|
||||
|
||||
delete m_windowManager;
|
||||
m_windowManager = nullptr;
|
||||
|
||||
|
||||
@@ -195,6 +195,10 @@ GHOST_SystemWin32::~GHOST_SystemWin32()
|
||||
if (isStartedFromCommandPrompt()) {
|
||||
setConsoleWindowState(GHOST_kConsoleWindowStateShow);
|
||||
}
|
||||
|
||||
/* We must call exit from here, since by the time ~GHOST_System calls it, the GHOST_SystemWin32
|
||||
* override is no longer reachable. */
|
||||
exit();
|
||||
}
|
||||
|
||||
uint64_t GHOST_SystemWin32::performanceCounterToMillis(__int64 perf_ticks) const
|
||||
@@ -661,7 +665,10 @@ GHOST_TSuccess GHOST_SystemWin32::init()
|
||||
|
||||
GHOST_TSuccess GHOST_SystemWin32::exit()
|
||||
{
|
||||
return GHOST_System::exit();
|
||||
GHOST_TSuccess success = GHOST_System::exit();
|
||||
/* All windows created with the specified class must be destroyed before unregistering it. */
|
||||
::UnregisterClassW(L"GHOST_WindowClass", ::GetModuleHandle(0));
|
||||
return success;
|
||||
}
|
||||
|
||||
GHOST_TKey GHOST_SystemWin32::hardKey(RAWINPUT const &raw, bool *r_key_down)
|
||||
|
||||
Reference in New Issue
Block a user