On Mon, 27 Apr 2020 at 13:19, Changbin Du <changbin...@gmail.com> wrote: > > I found SDL_GetWindowFromID() sometimes return NULL when I start qemu via > ssh forwarding even the window has been crated already. I am not sure > whether this is a bug of SDL, but we'd better check it carefully. > > Signed-off-by: Changbin Du <changbin...@gmail.com> > --- > ui/sdl2.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/ui/sdl2.c b/ui/sdl2.c > index 3c9424eb42..7c9c93b951 100644 > --- a/ui/sdl2.c > +++ b/ui/sdl2.c > @@ -332,6 +332,9 @@ static void handle_keydown(SDL_Event *ev) > int gui_key_modifier_pressed = get_mod_state(); > int gui_keysym = 0; > > + if (!scon) > + return; > + > if (!scon->ignore_hotkeys && gui_key_modifier_pressed && > !ev->key.repeat) { > switch (ev->key.keysym.scancode) { > case SDL_SCANCODE_2: > @@ -412,6 +415,9 @@ static void handle_keyup(SDL_Event *ev) > { > struct sdl2_console *scon = get_scon_from_window(ev->key.windowID); > > + if (!sconf) > + return;
It's generally a good idea to make sure your patch at least compiles before sending it :-) QEMU coding style demands {} on all if statements. thanks -- PMM