SL-18721 Don't 'post' window destruction, make thread do it automatically
parent
826236f1bc
commit
a620e58dac
|
|
@ -352,7 +352,12 @@ struct LLWindowWin32::LLWindowWin32Thread : public LL::ThreadPool
|
|||
|
||||
void run() override;
|
||||
|
||||
// closes queue, wakes thread, waits until thread closes
|
||||
// Detroys handles and window
|
||||
// Either post to or call from window thread
|
||||
void destroyWindow();
|
||||
|
||||
// Closes queue, wakes thread, waits until thread closes.
|
||||
// Call from main thread
|
||||
bool wakeAndDestroy();
|
||||
|
||||
void glReady()
|
||||
|
|
@ -424,7 +429,7 @@ struct LLWindowWin32::LLWindowWin32Thread : public LL::ThreadPool
|
|||
// *HACK: Attempt to prevent startup crashes by deferring memory accounting
|
||||
// until after some graphics setup. See SL-20177. -Cosmic,2023-09-18
|
||||
bool mGLReady = false;
|
||||
bool mDeleteOnExit = false;
|
||||
LLAtomicBool mDeleteOnExit = false;
|
||||
// best guess at available video memory in MB
|
||||
std::atomic<U32> mAvailableVRAM;
|
||||
|
||||
|
|
@ -873,6 +878,7 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,
|
|||
LLWindowWin32::~LLWindowWin32()
|
||||
{
|
||||
delete mDragDrop;
|
||||
mDragDrop = NULL;
|
||||
|
||||
delete [] mWindowTitle;
|
||||
mWindowTitle = NULL;
|
||||
|
|
@ -884,6 +890,7 @@ LLWindowWin32::~LLWindowWin32()
|
|||
mWindowClassName = NULL;
|
||||
|
||||
delete mWindowThread;
|
||||
mWindowThread = NULL;
|
||||
}
|
||||
|
||||
void LLWindowWin32::show()
|
||||
|
|
@ -4931,6 +4938,7 @@ void LLWindowWin32::LLWindowWin32Thread::run()
|
|||
#endif
|
||||
}
|
||||
|
||||
destroyWindow();
|
||||
cleanupDX();
|
||||
|
||||
if (mDeleteOnExit)
|
||||
|
|
@ -4939,6 +4947,35 @@ void LLWindowWin32::LLWindowWin32Thread::run()
|
|||
}
|
||||
}
|
||||
|
||||
void LLWindowWin32::LLWindowWin32Thread::destroyWindow()
|
||||
{
|
||||
if (mWindowHandleThrd != NULL && IsWindow(mWindowHandleThrd))
|
||||
{
|
||||
if (mhDCThrd)
|
||||
{
|
||||
if (!ReleaseDC(mWindowHandleThrd, mhDCThrd))
|
||||
{
|
||||
LL_WARNS("Window") << "Release of ghDC failed!" << LL_ENDL;
|
||||
}
|
||||
mhDCThrd = NULL;
|
||||
}
|
||||
|
||||
// This causes WM_DESTROY to be sent *immediately*
|
||||
if (!destroy_window_handler(mWindowHandleThrd))
|
||||
{
|
||||
LL_WARNS("Window") << "Failed to destroy Window! " << std::hex << GetLastError() << LL_ENDL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Something killed the window while we were busy destroying gl or handle somehow got broken
|
||||
LL_WARNS("Window") << "Failed to destroy Window, invalid handle!" << LL_ENDL;
|
||||
}
|
||||
mWindowHandleThrd = NULL;
|
||||
mhDCThrd = NULL;
|
||||
mGLReady = false;
|
||||
}
|
||||
|
||||
bool LLWindowWin32::LLWindowWin32Thread::wakeAndDestroy()
|
||||
{
|
||||
if (mQueue->isClosed())
|
||||
|
|
@ -4954,35 +4991,6 @@ bool LLWindowWin32::LLWindowWin32Thread::wakeAndDestroy()
|
|||
|
||||
// Schedule destruction
|
||||
HWND old_handle = mWindowHandleThrd;
|
||||
post([this]()
|
||||
{
|
||||
if (IsWindow(mWindowHandleThrd))
|
||||
{
|
||||
if (mhDCThrd)
|
||||
{
|
||||
if (!ReleaseDC(mWindowHandleThrd, mhDCThrd))
|
||||
{
|
||||
LL_WARNS("Window") << "Release of ghDC failed!" << LL_ENDL;
|
||||
}
|
||||
mhDCThrd = NULL;
|
||||
}
|
||||
|
||||
// This causes WM_DESTROY to be sent *immediately*
|
||||
if (!destroy_window_handler(mWindowHandleThrd))
|
||||
{
|
||||
LL_WARNS("Window") << "Failed to destroy Window! " << std::hex << GetLastError() << LL_ENDL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Something killed the window while we were busy destroying gl or handle somehow got broken
|
||||
LL_WARNS("Window") << "Failed to destroy Window, invalid handle!" << LL_ENDL;
|
||||
}
|
||||
mWindowHandleThrd = NULL;
|
||||
mhDCThrd = NULL;
|
||||
mGLReady = false;
|
||||
});
|
||||
|
||||
mDeleteOnExit = true;
|
||||
SetWindowLongPtr(old_handle, GWLP_USERDATA, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -2041,7 +2041,7 @@ bool LLAppViewer::cleanup()
|
|||
|
||||
sTextureFetch->shutDownTextureCacheThread() ;
|
||||
LLLFSThread::sLocal->shutdown();
|
||||
ms_sleep(200);
|
||||
|
||||
LL_INFOS() << "Shutting down OpenGL" << LL_ENDL;
|
||||
|
||||
// Shut down OpenGL
|
||||
|
|
|
|||
Loading…
Reference in New Issue