diff options
author | Ansariel <ansariel.hiller@phoenixviewer.com> | 2024-10-15 23:49:00 +0200 |
---|---|---|
committer | Ansariel <ansariel.hiller@phoenixviewer.com> | 2024-10-15 23:49:00 +0200 |
commit | 401f7eecb5c011a330046ac125ce14562de7ab5e (patch) | |
tree | 78681b7988bdd672759aba85193ae8dc7692a1d1 | |
parent | b68557d9fe6cfdfafc3e9c609c1c8b799eb62f9f (diff) |
Fix more merge issues:
* Re-apply changes from a620e58daccf92b5b8d61347312739720ed2b51a
* Fix duplicate code resulting from 826236f1bc065fba257d7954d11ac98c59493445
-rw-r--r-- | indra/llwindow/llwindowwin32.cpp | 71 | ||||
-rw-r--r-- | indra/newview/llappviewer.cpp | 32 |
2 files changed, 40 insertions, 63 deletions
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 9494eee46d..bacf5325fe 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -344,7 +344,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() @@ -402,7 +407,7 @@ struct LLWindowWin32::LLWindowWin32Thread : public LL::ThreadPool // until after some graphics setup. See SL-20177. -Cosmic,2023-09-18 bool mGLReady = false; bool mGotGLBuffer = false; - bool mDeleteOnExit = false; + LLAtomicBool mDeleteOnExit = false; }; @@ -4785,17 +4790,48 @@ void LLWindowWin32::LLWindowWin32Thread::run() #endif } + destroyWindow(); + if (mDeleteOnExit) { delete this; } } +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()) { - LL_WARNS() << "Tried to close Queue. Win32 thread Queue already closed." << LL_ENDL; + LL_WARNS() << "Tried to close Queue. Win32 thread Queue already closed." <<LL_ENDL; return false; } @@ -4806,35 +4842,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); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 58fde3d9ec..23da0faa47 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2002,37 +2002,6 @@ bool LLAppViewer::cleanup() // Clean up before GL is shut down because we might be holding on to objects with texture references LLSelectMgr::cleanupGlobals(); - LL_INFOS() << "Shutting down OpenGL" << LL_ENDL; - - // Shut down OpenGL - if( gViewerWindow) - { - gViewerWindow->shutdownGL(); - - // Destroy window, and make sure we're not fullscreen - // This may generate window reshape and activation events. - // Therefore must do this before destroying the message system. - delete gViewerWindow; - gViewerWindow = NULL; - LL_INFOS() << "ViewerWindow deleted" << LL_ENDL; - } - - LLSplashScreen::show(); - LLSplashScreen::update(LLTrans::getString("ShuttingDown")); - - LL_INFOS() << "Cleaning up Keyboard & Joystick" << LL_ENDL; - - // viewer UI relies on keyboard so keep it aound until viewer UI isa gone - delete gKeyboard; - gKeyboard = NULL; - - if (LLViewerJoystick::instanceExists()) - { - // Turn off Space Navigator and similar devices - LLViewerJoystick::getInstance()->terminate(); - } - LLGameControl::terminate(); - LL_INFOS() << "Cleaning up Objects" << LL_ENDL; LLViewerObject::cleanupVOClasses(); @@ -2220,6 +2189,7 @@ bool LLAppViewer::cleanup() // Turn off Space Navigator and similar devices LLViewerJoystick::getInstance()->terminate(); } + LLGameControl::terminate(); LL_INFOS() << "Shutting down message system" << LL_ENDL; end_messaging_system(); |