| Summary: | SDL_Init(SDL_INIT_VIDEO) always sets error on Win 7 and below | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Jason Francis <jason> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | minor | ||
| Priority: | P2 | CC: | amaranth72 |
| Version: | 2.0.4 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 7 | ||
| Attachments: |
Remove SDL_LoadObject and SDL_LoadFunction calls in WIN_CreateDevice
Test case |
||
|
Description
Jason Francis
2016-05-05 22:25:47 UTC
Created attachment 2447 [details]
Test case
Attached a test case. This will always print an error about SHCORE.DLL missing on Win7, but will print nothing on Win8.1 or Win10. I don't have access to a Win8 machine to test.
A much simpler solution would be clearing the error, e.g.:
diff -r 7cbfd97f1430 src/video/windows/SDL_windowsvideo.c
--- a/src/video/windows/SDL_windowsvideo.c Mon May 23 15:29:25 2016 -0300
+++ b/src/video/windows/SDL_windowsvideo.c Tue May 24 10:55:10 2016 +0300
@@ -119,6 +119,9 @@ WIN_CreateDevice(int devindex)
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 */
device->VideoInit = WIN_VideoInit;
Note that SDL_GetError should *only* be used when a SDL function returns indicating an error (-1 or NULL, usually). SDL_GetError should not be used for checking whether an error has occurred at all - it may return anything it wants. You should only check the SDL error if an API function fails. That said, this was cleaned up in this commit: https://hg.libsdl.org/SDL/rev/f94279990934 |