@@ -412,8 +412,8 @@ struct LLWindowWin32::LLWindowWin32Thread : public LL::ThreadPool
412
412
using FuncType = std::function<void ()>;
413
413
// call GetMessage() and pull enqueue messages for later processing
414
414
void gatherInput ();
415
- HWND mWindowHandle = NULL ;
416
- HDC mhDC = 0 ;
415
+ HWND mWindowHandleThrd = NULL ;
416
+ HDC mhDCThrd = 0 ;
417
417
418
418
// *HACK: Attempt to prevent startup crashes by deferring memory accounting
419
419
// until after some graphics setup. See SL-20177. -Cosmic,2023-09-18
@@ -987,23 +987,23 @@ void LLWindowWin32::close()
987
987
988
988
LL_DEBUGS (" Window" ) << " Destroying Window" << LL_ENDL;
989
989
990
- mWindowThread ->post ([= ]()
990
+ mWindowThread ->post ([this , self = mWindowThread ]()
991
991
{
992
- if (IsWindow (mWindowHandle ))
992
+ if (IsWindow (self-> mWindowHandleThrd ))
993
993
{
994
- if (mhDC )
994
+ if (self-> mhDCThrd )
995
995
{
996
- if (!ReleaseDC (mWindowHandle , mhDC ))
996
+ if (!ReleaseDC (self-> mWindowHandleThrd , self-> mhDCThrd ))
997
997
{
998
998
LL_WARNS (" Window" ) << " Release of ghDC failed!" << LL_ENDL;
999
999
}
1000
1000
}
1001
1001
1002
1002
// Make sure we don't leave a blank toolbar button.
1003
- ShowWindow (mWindowHandle , SW_HIDE);
1003
+ ShowWindow (self-> mWindowHandleThrd , SW_HIDE);
1004
1004
1005
1005
// This causes WM_DESTROY to be sent *immediately*
1006
- if (!destroy_window_handler (mWindowHandle ))
1006
+ if (!destroy_window_handler (self-> mWindowHandleThrd ))
1007
1007
{
1008
1008
OSMessageBox (mCallbacks ->translateString (" MBDestroyWinFailed" ),
1009
1009
mCallbacks ->translateString (" MBShutdownErr" ),
@@ -1015,17 +1015,18 @@ void LLWindowWin32::close()
1015
1015
// Something killed the window while we were busy destroying gl or handle somehow got broken
1016
1016
LL_WARNS (" Window" ) << " Failed to destroy Window, invalid handle!" << LL_ENDL;
1017
1017
}
1018
-
1018
+ self->mWindowHandleThrd = NULL ;
1019
+ self->mhDCThrd = NULL ;
1020
+ self->mGLReady = false ;
1019
1021
});
1020
- // Window thread might be waiting for a getMessage(), give it
1021
- // a push to enshure it will process destroy_window_handler
1022
- kickWindowThread ();
1023
1022
1024
- // Even though the above lambda might not yet have run, we've already
1025
- // bound mWindowHandle into it by value, which should suffice for the
1026
- // operations we're asking. That's the last time WE should touch it.
1027
1023
mhDC = NULL ;
1028
1024
mWindowHandle = NULL ;
1025
+
1026
+ // Window thread might be waiting for a getMessage(), give it
1027
+ // a push to enshure it will process destroy_window_handler
1028
+ kickWindowThread ();
1029
+
1029
1030
mWindowThread ->close ();
1030
1031
}
1031
1032
@@ -1777,8 +1778,8 @@ void LLWindowWin32::recreateWindow(RECT window_rect, DWORD dw_ex_style, DWORD dw
1777
1778
()
1778
1779
{
1779
1780
LL_DEBUGS (" Window" ) << " recreateWindow(): window_work entry" << LL_ENDL;
1780
- self->mWindowHandle = 0 ;
1781
- self->mhDC = 0 ;
1781
+ self->mWindowHandleThrd = 0 ;
1782
+ self->mhDCThrd = 0 ;
1782
1783
1783
1784
if (oldWindowHandle)
1784
1785
{
@@ -1813,20 +1814,20 @@ void LLWindowWin32::recreateWindow(RECT window_rect, DWORD dw_ex_style, DWORD dw
1813
1814
{
1814
1815
// Failed to create window: clear the variables. This
1815
1816
// assignment is valid because we're running on mWindowThread.
1816
- self->mWindowHandle = NULL ;
1817
- self->mhDC = 0 ;
1817
+ self->mWindowHandleThrd = NULL ;
1818
+ self->mhDCThrd = 0 ;
1818
1819
}
1819
1820
else
1820
1821
{
1821
1822
// Update mWindowThread's own mWindowHandle and mhDC.
1822
- self->mWindowHandle = handle;
1823
- self->mhDC = GetDC (handle);
1823
+ self->mWindowHandleThrd = handle;
1824
+ self->mhDCThrd = GetDC (handle);
1824
1825
}
1825
1826
1826
1827
updateWindowRect ();
1827
1828
1828
1829
// It's important to wake up the future either way.
1829
- promise.set_value (std::make_pair (self->mWindowHandle , self->mhDC ));
1830
+ promise.set_value (std::make_pair (self->mWindowHandleThrd , self->mhDCThrd ));
1830
1831
LL_DEBUGS (" Window" ) << " recreateWindow(): window_work done" << LL_ENDL;
1831
1832
};
1832
1833
// But how we pass window_work to the window thread depends on whether we
@@ -4589,7 +4590,7 @@ U32 LLWindowWin32::getAvailableVRAMMegabytes()
4589
4590
#endif // LL_WINDOWS
4590
4591
4591
4592
inline LLWindowWin32::LLWindowWin32Thread::LLWindowWin32Thread ()
4592
- : LL::ThreadPool(" Window Thread" , 1 , MAX_QUEUE_SIZE)
4593
+ : LL::ThreadPool(" Window Thread" , 1 , MAX_QUEUE_SIZE, false )
4593
4594
{
4594
4595
LL::ThreadPool::start ();
4595
4596
}
@@ -4745,7 +4746,7 @@ void LLWindowWin32::LLWindowWin32Thread::initD3D()
4745
4746
{
4746
4747
if (!mGLReady ) { return ; }
4747
4748
4748
- if (mDXGIAdapter == NULL && mD3DDevice == NULL && mWindowHandle != 0 )
4749
+ if (mDXGIAdapter == NULL && mD3DDevice == NULL && mWindowHandleThrd != 0 )
4749
4750
{
4750
4751
mD3D = Direct3DCreate9 (D3D_SDK_VERSION);
4751
4752
@@ -4755,7 +4756,7 @@ void LLWindowWin32::LLWindowWin32Thread::initD3D()
4755
4756
d3dpp.Windowed = TRUE ;
4756
4757
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
4757
4758
4758
- HRESULT res = mD3D ->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, mWindowHandle , D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &mD3DDevice );
4759
+ HRESULT res = mD3D ->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, mWindowHandleThrd , D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &mD3DDevice );
4759
4760
4760
4761
if (FAILED (res))
4761
4762
{
@@ -4861,24 +4862,24 @@ void LLWindowWin32::LLWindowWin32Thread::run()
4861
4862
// lazily call initD3D inside this loop to catch when mGLReady has been set to true
4862
4863
initDX ();
4863
4864
4864
- if (mWindowHandle != 0 )
4865
+ if (mWindowHandleThrd != 0 )
4865
4866
{
4866
4867
// lazily call initD3D inside this loop to catch when mWindowHandle has been set, and mGLReady has been set to true
4867
4868
// *TODO: Shutdown if this fails when mWindowHandle exists
4868
4869
initD3D ();
4869
4870
4870
4871
MSG msg;
4871
4872
BOOL status;
4872
- if (mhDC == 0 )
4873
+ if (mhDCThrd == 0 )
4873
4874
{
4874
4875
LL_PROFILE_ZONE_NAMED_CATEGORY_WIN32 (" w32t - PeekMessage" );
4875
- logger.onChange (" PeekMessage(" , std::hex, mWindowHandle , " )" );
4876
- status = PeekMessage (&msg, mWindowHandle , 0 , 0 , PM_REMOVE);
4876
+ logger.onChange (" PeekMessage(" , std::hex, mWindowHandleThrd , " )" );
4877
+ status = PeekMessage (&msg, mWindowHandleThrd , 0 , 0 , PM_REMOVE);
4877
4878
}
4878
4879
else
4879
4880
{
4880
4881
LL_PROFILE_ZONE_NAMED_CATEGORY_WIN32 (" w32t - GetMessage" );
4881
- logger.always (" GetMessage(" , std::hex, mWindowHandle , " )" );
4882
+ logger.always (" GetMessage(" , std::hex, mWindowHandleThrd , " )" );
4882
4883
status = GetMessage (&msg, NULL , 0 , 0 );
4883
4884
}
4884
4885
if (status > 0 )
0 commit comments