mirror of
https://github.com/glfw/glfw.git
synced 2025-07-29 11:00:04 +00:00
Add error checks.
This commit is contained in:
parent
763ec6cbcb
commit
cfda347264
@ -37,6 +37,20 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
|
||||||
|
// Error handler used when creating a blank cursor
|
||||||
|
//
|
||||||
|
static int errorHandler(Display *display, XErrorEvent* event)
|
||||||
|
{
|
||||||
|
char buffer[8192];
|
||||||
|
XGetErrorText(display,
|
||||||
|
event->error_code,
|
||||||
|
buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to create a blank cursor: %s", buffer);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Translate an X11 key code to a GLFW key code.
|
// Translate an X11 key code to a GLFW key code.
|
||||||
//
|
//
|
||||||
static int translateKey(int keyCode)
|
static int translateKey(int keyCode)
|
||||||
@ -553,7 +567,7 @@ static Cursor createNULLCursor(void)
|
|||||||
XColor col;
|
XColor col;
|
||||||
Cursor cursor;
|
Cursor cursor;
|
||||||
|
|
||||||
// TODO: Add error checks
|
XSetErrorHandler(errorHandler);
|
||||||
|
|
||||||
cursormask = XCreatePixmap(_glfw.x11.display, _glfw.x11.root, 1, 1, 1);
|
cursormask = XCreatePixmap(_glfw.x11.display, _glfw.x11.root, 1, 1, 1);
|
||||||
xgc.function = GXclear;
|
xgc.function = GXclear;
|
||||||
@ -568,6 +582,9 @@ static Cursor createNULLCursor(void)
|
|||||||
XFreePixmap(_glfw.x11.display, cursormask);
|
XFreePixmap(_glfw.x11.display, cursormask);
|
||||||
XFreeGC(_glfw.x11.display, gc);
|
XFreeGC(_glfw.x11.display, gc);
|
||||||
|
|
||||||
|
XSync(_glfw.x11.display, False);
|
||||||
|
XSetErrorHandler(NULL);
|
||||||
|
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user