diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2020-11-19 16:56:10 +0000 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2020-11-19 16:56:10 +0000 |
commit | a55ec705855d169e953cec10b42b156a3423fd94 (patch) | |
tree | 7d6b471ce948c87397cc8f25f13732fb1d34f93d /indra/llwindow | |
parent | 12d2bf47865559a8da087f6e3bbb4b65d421169c (diff) |
SL-14347 Crash at ChoosePixelFormat
Diffstat (limited to 'indra/llwindow')
-rw-r--r-- | indra/llwindow/llwindowwin32.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index a541e06c93..28e835a5fa 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -461,7 +461,8 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks, memset(mCurrentGammaRamp, 0, sizeof(mCurrentGammaRamp)); memset(mPrevGammaRamp, 0, sizeof(mPrevGammaRamp)); mCustomGammaSet = FALSE; - + mWindowHandle = NULL; + if (!SystemParametersInfo(SPI_GETMOUSEVANISH, 0, &mMouseVanish, 0)) { mMouseVanish = TRUE; @@ -1171,7 +1172,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO << " Height: " << (window_rect.bottom - window_rect.top) << " Fullscreen: " << mFullscreen << LL_ENDL; - if (!destroy_window_handler(mWindowHandle)) + if (mWindowHandle && !destroy_window_handler(mWindowHandle)) { LL_WARNS("Window") << "Failed to properly close window before recreating it!" << LL_ENDL; } @@ -1230,13 +1231,26 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO LL_INFOS("Window") << "Device context retrieved." << LL_ENDL ; - if (!(pixel_format = ChoosePixelFormat(mhDC, &pfd))) - { - close(); - OSMessageBox(mCallbacks->translateString("MBPixelFmtErr"), - mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } + try + { + // Looks like ChoosePixelFormat can crash in case of faulty driver + if (!(pixel_format = ChoosePixelFormat(mhDC, &pfd))) + { + LL_WARNS("Window") << "ChoosePixelFormat failed, code: " << GetLastError() << LL_ENDL; + OSMessageBox(mCallbacks->translateString("MBPixelFmtErr"), + mCallbacks->translateString("MBError"), OSMB_OK); + close(); + return FALSE; + } + } + catch (...) + { + LL_WARNS("Window") << "ChoosePixelFormat failed." << LL_ENDL; + OSMessageBox(mCallbacks->translateString("MBPixelFmtErr"), + mCallbacks->translateString("MBError"), OSMB_OK); + close(); + return FALSE; + } LL_INFOS("Window") << "Pixel format chosen." << LL_ENDL ; @@ -1496,7 +1510,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO } // Destroy The Window - if (!destroy_window_handler(mWindowHandle)) + if (mWindowHandle && !destroy_window_handler(mWindowHandle)) { LL_WARNS("Window") << "Failed to properly close window!" << LL_ENDL; } |