comparison src/events/SDL_keyboard.c @ 4437:25e45611fa3d

Fix a crash caused by empty keyboard focus --- src/events/SDL_keyboard.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
author Jjgod Jiang <gzjjgod@gmail.com>
date Tue, 20 Apr 2010 07:16:42 -0700
parents e953700da4ca
children 3e69e077cb95 ba38983b10c2
comparison
equal deleted inserted replaced
4436:d3c193100522 4437:25e45611fa3d
811 event.key.state = state; 811 event.key.state = state;
812 event.key.keysym.scancode = scancode; 812 event.key.keysym.scancode = scancode;
813 event.key.keysym.sym = keyboard->keymap[scancode]; 813 event.key.keysym.sym = keyboard->keymap[scancode];
814 event.key.keysym.mod = modstate; 814 event.key.keysym.mod = modstate;
815 event.key.keysym.unicode = 0; 815 event.key.keysym.unicode = 0;
816 event.key.windowID = keyboard->focus->id; 816 event.key.windowID = keyboard->focus ? keyboard->focus->id : 0;
817 posted = (SDL_PushEvent(&event) > 0); 817 posted = (SDL_PushEvent(&event) > 0);
818 } 818 }
819 return (posted); 819 return (posted);
820 } 820 }
821 821
835 SDL_Event event; 835 SDL_Event event;
836 event.text.type = SDL_TEXTINPUT; 836 event.text.type = SDL_TEXTINPUT;
837 event.text.windowID = keyboard->focus ? keyboard->focus->id : 0; 837 event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
838 event.text.which = (Uint8) index; 838 event.text.which = (Uint8) index;
839 SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text)); 839 SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
840 event.text.windowID = keyboard->focus->id; 840 event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
841 posted = (SDL_PushEvent(&event) > 0); 841 posted = (SDL_PushEvent(&event) > 0);
842 } 842 }
843 return (posted); 843 return (posted);
844 } 844 }
845 845