summaryrefslogtreecommitdiff
path: root/indra/llwindow/llwindowwin32.cpp
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2020-12-01 18:21:43 +0200
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2020-12-01 18:22:24 +0200
commitbb4d02446fa215520a11f219ebca453d2dea0388 (patch)
tree8cb5800186d26d824bf6aed92654d851398adfba /indra/llwindow/llwindowwin32.cpp
parent6d06c8b9de4708c4b8d8c68ae5fe4d753b9d70ca (diff)
SL-14347 Crash at ChoosePixelFormat SEH
Diffstat (limited to 'indra/llwindow/llwindowwin32.cpp')
-rw-r--r--indra/llwindow/llwindowwin32.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index 28e835a5fa..36148190fa 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -38,6 +38,7 @@
// Linden library includes
#include "llerror.h"
+#include "llexception.h"
#include "llfasttimer.h"
#include "llgl.h"
#include "llstring.h"
@@ -117,7 +118,7 @@ void show_window_creation_error(const std::string& title)
LL_WARNS("Window") << title << LL_ENDL;
}
-HGLRC SafeCreateContext(HDC hdc)
+HGLRC SafeCreateContext(HDC &hdc)
{
__try
{
@@ -129,6 +130,22 @@ HGLRC SafeCreateContext(HDC hdc)
}
}
+GLuint SafeChoosePixelFormat(HDC &hdc, const PIXELFORMATDESCRIPTOR *ppfd)
+{
+ __try
+ {
+ return ChoosePixelFormat(hdc, ppfd);
+ }
+ __except (EXCEPTION_EXECUTE_HANDLER)
+ {
+ // convert to C++ styled exception
+ // C exception don't allow classes, so it's a regular char array
+ char integer_string[32];
+ sprintf(integer_string, "SEH, code: %lu\n", GetExceptionCode());
+ throw std::exception(integer_string);
+ }
+}
+
//static
BOOL LLWindowWin32::sIsClassRegistered = FALSE;
@@ -1234,7 +1251,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
try
{
// Looks like ChoosePixelFormat can crash in case of faulty driver
- if (!(pixel_format = ChoosePixelFormat(mhDC, &pfd)))
+ if (!(pixel_format = SafeChoosePixelFormat(mhDC, &pfd)))
{
LL_WARNS("Window") << "ChoosePixelFormat failed, code: " << GetLastError() << LL_ENDL;
OSMessageBox(mCallbacks->translateString("MBPixelFmtErr"),
@@ -1245,7 +1262,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
}
catch (...)
{
- LL_WARNS("Window") << "ChoosePixelFormat failed." << LL_ENDL;
+ LOG_UNHANDLED_EXCEPTION("ChoosePixelFormat");
OSMessageBox(mCallbacks->translateString("MBPixelFmtErr"),
mCallbacks->translateString("MBError"), OSMB_OK);
close();