Fixed bug 3702 - Clear error messages of SDL_LoadObject for optional libraries

Simon Hug

Some code in SDL loads libraries with SDL_LoadObject to get more information or use newer APIs. SDL_LoadObject may fail, set an error message and SDL will continue with some fallback code. Since SDL will overwrite the error or exit the function with a return value that indicates success, the error form SDL_LoadObject for the optional stuff might as well be cleared right away.
This commit is contained in:
Sam Lantinga 2017-08-11 10:21:19 -07:00
parent 6e1b11bae4
commit 96305832bc
4 changed files with 9 additions and 1 deletions

View File

@ -150,6 +150,7 @@ LoadLibSampleRate(void)
SDL_assert(SRC_lib == NULL);
SRC_lib = SDL_LoadObject(SDL_LIBSAMPLERATE_DYNAMIC);
if (!SRC_lib) {
SDL_ClearError();
return SDL_FALSE;
}

View File

@ -269,7 +269,9 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
}
}
if (SDL_strcasecmp(d3dcompiler, "none") != 0) {
SDL_LoadObject(d3dcompiler);
if (SDL_LoadObject(d3dcompiler) == NULL) {
SDL_ClearError();
}
}
#endif

View File

@ -351,6 +351,7 @@ IME_Init(SDL_VideoData *videodata, HWND hwnd)
videodata->ime_himm32 = SDL_LoadObject("imm32.dll");
if (!videodata->ime_himm32) {
videodata->ime_available = SDL_FALSE;
SDL_ClearError();
return;
}
videodata->ImmLockIMC = (LPINPUTCONTEXT2 (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMC");

View File

@ -113,11 +113,15 @@ WIN_CreateDevice(int devindex)
data->CloseTouchInputHandle = (BOOL (WINAPI *)(HTOUCHINPUT)) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle");
data->GetTouchInputInfo = (BOOL (WINAPI *)(HTOUCHINPUT, UINT, PTOUCHINPUT, int)) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo");
data->RegisterTouchWindow = (BOOL (WINAPI *)(HWND, ULONG)) SDL_LoadFunction(data->userDLL, "RegisterTouchWindow");
} else {
SDL_ClearError();
}
data->shcoreDLL = SDL_LoadObject("SHCORE.DLL");
if (data->shcoreDLL) {
data->GetDpiForMonitor = (HRESULT (WINAPI *)(HMONITOR, MONITOR_DPI_TYPE, UINT *, UINT *)) SDL_LoadFunction(data->shcoreDLL, "GetDpiForMonitor");
} else {
SDL_ClearError();
}
/* Set the function pointers */