summaryrefslogtreecommitdiff
path: root/indra/llwindow/llwindowwin32.cpp
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2020-11-19 16:56:10 +0000
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2021-01-04 16:48:46 +0200
commit1a8800b051166d3406065df312c66b7e4f00fe05 (patch)
tree57251a917ca64d12d46f79d8c0f912ec5b59608b /indra/llwindow/llwindowwin32.cpp
parent9962df9fb7303dc52f52bf448bef407342286008 (diff)
SL-14347 Crash at ChoosePixelFormat
Diffstat (limited to 'indra/llwindow/llwindowwin32.cpp')
-rw-r--r--indra/llwindow/llwindowwin32.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index 8ec85976c3..6831071cd1 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -428,7 +428,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;
@@ -1169,7 +1170,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;
}
@@ -1228,13 +1229,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 ;
@@ -1494,7 +1508,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;
}