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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 1243721..120555f 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -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;
}
diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
index ed0feb4..20884af 100644
--- a/src/video/SDL_egl.c
+++ b/src/video/SDL_egl.c
@@ -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
diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c
index 2018a30..7e79c6f 100644
--- a/src/video/windows/SDL_windowskeyboard.c
+++ b/src/video/windows/SDL_windowskeyboard.c
@@ -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");
diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c
index 4b180c3..f6fc6f4 100644
--- a/src/video/windows/SDL_windowsvideo.c
+++ b/src/video/windows/SDL_windowsvideo.c
@@ -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 */