Fixed bug - put array unregister function after line input into correct thread
[rodin/chimara.git] / libchimara / event.c
index 4bbb391b597bb028dc7e5a75994de54ee188858f..ca5e21aac58a874dd7a28a1ebc968601e925deab 100644 (file)
@@ -1,6 +1,7 @@
 #include "event.h"
 #include "magic.h"
 #include "glk.h"
+#include "window.h"
 #include <string.h>
 
 #include "chimara-glk.h"
@@ -92,6 +93,15 @@ glk_select(event_t *event)
        
        /* Check for interrupt */
        glk_tick();
+
+       /* If the event was a line input event, the library must release the buffer */
+       if(event->type == evtype_LineInput && glk_data->unregister_arr) 
+       {
+        if(event->win->input_request_type == INPUT_REQUEST_LINE_UNICODE)
+                       (*glk_data->unregister_arr)(event->win->line_input_buffer_unicode, event->win->line_input_buffer_max_len, "&+#!Iu", event->win->buffer_rock);
+               else
+            (*glk_data->unregister_arr)(event->win->line_input_buffer, event->win->line_input_buffer_max_len, "&+#!Cn", event->win->buffer_rock);
+    }
        
        /* If an abort event was generated, the thread should have exited by now */
        g_assert(event->type != evtype_Abort);