Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL_GetError() returns "Parameter 'src' is invalid" after call to initscr() for sdl2 #145

Open
bjadamson opened this issue May 16, 2023 · 2 comments

Comments

@bjadamson
Copy link

In this code path, SDL_GetError returns "Parameter 'src' is invalid" after the call to initscr.

The error comes from this code:

PDCurses/sdl2/pdcscrn.c

Lines 233 to 237 in f2d31a2

if (!SP->mono && !pdc_back)
{
const char *bname = getenv("PDC_BACKGROUND");
pdc_back = SDL_LoadBMP(bname ? bname : "pdcback.bmp");
}

I guess it's not valid to call SDL_LoadBMP with NULL. Obviously I can work-around this by calling SDL_ClearError immediately after the call to initscr() but I think it would be cleaner long-term if this call causing an invalid error could be avoided in the first place.

I found this out because I started annotating all of my calls to SDL with checks using SDL_GetError(), and this came up.

@wmcbrine
Copy link
Owner

Eh, the point of bname ? bname : "pdcback.bmp" is precisely to avoid passing a NULL to SDL_LoadBMP.

@bjadamson
Copy link
Author

Your right, I misunderstood what was happening yesterday. It's falling back to "pdcback.bmp" but that file doesn't exist, so SDL calls SDL_SetError which lead to the issue.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants