mirror of https://github.com/libsdl-org/SDL.git
hidapi: improved error handling
This commit is contained in:
parent
2666e15cf1
commit
211054d9db
|
|
@ -133,7 +133,11 @@ static void register_error_str(wchar_t **error_str, const char *msg)
|
||||||
free(*error_str);
|
free(*error_str);
|
||||||
#ifdef HIDAPI_USING_SDL_RUNTIME
|
#ifdef HIDAPI_USING_SDL_RUNTIME
|
||||||
/* Thread-safe error handling */
|
/* Thread-safe error handling */
|
||||||
SDL_SetError("%s", msg);
|
if (msg) {
|
||||||
|
SDL_SetError("%s", msg);
|
||||||
|
} else {
|
||||||
|
SDL_ClearError();
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
*error_str = utf8_to_wchar_t(msg);
|
*error_str = utf8_to_wchar_t(msg);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,11 @@ static void register_error_str(wchar_t **error_str, const char *msg)
|
||||||
free(*error_str);
|
free(*error_str);
|
||||||
#ifdef HIDAPI_USING_SDL_RUNTIME
|
#ifdef HIDAPI_USING_SDL_RUNTIME
|
||||||
/* Thread-safe error handling */
|
/* Thread-safe error handling */
|
||||||
SDL_SetError("%s", msg);
|
if (msg) {
|
||||||
|
SDL_SetError("%s", msg);
|
||||||
|
} else {
|
||||||
|
SDL_ClearError();
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
*error_str = utf8_to_wchar_t(msg);
|
*error_str = utf8_to_wchar_t(msg);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -258,6 +258,11 @@ static void register_winapi_error_to_buffer(wchar_t **error_buffer, const WCHAR
|
||||||
free(*error_buffer);
|
free(*error_buffer);
|
||||||
*error_buffer = NULL;
|
*error_buffer = NULL;
|
||||||
|
|
||||||
|
#ifdef HIDAPI_USING_SDL_RUNTIME
|
||||||
|
/* Thread-safe error handling */
|
||||||
|
SDL_ClearError();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Only clear out error messages if NULL is passed into op */
|
/* Only clear out error messages if NULL is passed into op */
|
||||||
if (!op) {
|
if (!op) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -334,18 +339,20 @@ static void register_string_error_to_buffer(wchar_t **error_buffer, const WCHAR
|
||||||
free(*error_buffer);
|
free(*error_buffer);
|
||||||
*error_buffer = NULL;
|
*error_buffer = NULL;
|
||||||
|
|
||||||
if (string_error) {
|
|
||||||
#ifdef HIDAPI_USING_SDL_RUNTIME
|
#ifdef HIDAPI_USING_SDL_RUNTIME
|
||||||
/* Thread-safe error handling */
|
/* Thread-safe error handling */
|
||||||
char *error_utf8 = SDL_iconv_wchar_utf8(string_error);
|
char *error_utf8 = string_error ? SDL_iconv_wchar_utf8(string_error) : NULL;
|
||||||
if (error_utf8) {
|
if (error_utf8) {
|
||||||
SDL_SetError("%s", error_utf8);
|
SDL_SetError("%s", error_utf8);
|
||||||
SDL_free(error_utf8);
|
SDL_free(error_utf8);
|
||||||
}
|
} else {
|
||||||
#else
|
SDL_ClearError();
|
||||||
*error_buffer = _wcsdup(string_error);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (string_error) {
|
||||||
|
*error_buffer = _wcsdup(string_error);
|
||||||
|
}
|
||||||
|
#endif /* HIDAPI_USING_SDL_RUNTIME */
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue