Don't call SDL_GetWindowDisplayIndex() with window == NULL

I got an SDL assertion because of this.
The problem was that PrintDisplayModes() was called at startup before a
window was created.
This commit is contained in:
Daniel Gibson 2019-09-22 19:09:10 +02:00
parent 9bb0425e36
commit 77493e6e5b
1 changed files with 2 additions and 1 deletions

View File

@ -263,10 +263,11 @@ InitDisplayIndices()
static void
PrintDisplayModes(void)
{
int curdisplay = SDL_GetWindowDisplayIndex(window);
int curdisplay = window ? SDL_GetWindowDisplayIndex(window) : 0;
// On X11 (at least for me)
// curdisplay is always -1.
// DG: probably because window was NULL?
if (curdisplay < 0) {
curdisplay = 0;
}