* cancel_line_input_event now handles an NULL event parameter correctly
authorrodin <rodin@ddfedd41-794f-dd11-ae45-00112f111e67>
Fri, 22 May 2009 10:43:57 +0000 (10:43 +0000)
committerrodin <rodin@ddfedd41-794f-dd11-ae45-00112f111e67>
Fri, 22 May 2009 10:43:57 +0000 (10:43 +0000)
 * cancel_line_input_event will now fail quietly on INPUT_REQUEST_NONE

src/input.c

index 89356fae2ff913d8f9a6c07e085ca9556dad067a..81b1664cfc161b530175821f9c0ecaf0b9e3f90d 100644 (file)
@@ -276,15 +276,18 @@ glk_request_line_event_uni(winid_t win, glui32 *buf, glui32 maxlen, glui32 initl
 void
 glk_cancel_line_event(winid_t win, event_t *event)
 {
-       /* TODO: write me */
        VALID_WINDOW(win, return);
-       g_return_if_fail(win->input_request_type != INPUT_REQUEST_NONE);
        g_return_if_fail(win->type != wintype_TextBuffer || win->type != wintype_TextGrid);
 
-       event->type = evtype_None;
-       event->win = win;
-       event->val1 = 0;
-       event->val2 = 0;
+       if(event != NULL) {
+               event->type = evtype_None;
+               event->win = win;
+               event->val1 = 0;
+               event->val2 = 0;
+       }
+
+       if(win->input_request_type == INPUT_REQUEST_NONE)
+               return;
 
        g_signal_handler_block( G_OBJECT(win->widget), win->keypress_handler );
 
@@ -299,7 +302,7 @@ glk_cancel_line_event(winid_t win, event_t *event)
                chars_written = flush_text_buffer(win);
        }
 
-       if(chars_written > 0) {
+       if(event != NULL && chars_written > 0) {
                event->type = evtype_LineInput;
                event->val1 = chars_written;
        }