Fixed bug - put array unregister function after line input into correct thread
authorPhilip Chimento <philip.chimento@gmail.com>
Wed, 7 Oct 2009 21:14:29 +0000 (21:14 +0000)
committerPhilip Chimento <philip.chimento@gmail.com>
Wed, 7 Oct 2009 21:14:29 +0000 (21:14 +0000)
git-svn-id: http://lassie.dyndns-server.com/svn/gargoyle-gtk@135 ddfedd41-794f-dd11-ae45-00112f111e67

libchimara/event.c
libchimara/input.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);
index 7394ce3b702b458b73fc9cdbaecffd7065d7d14e..44334b40f660c9e6c9316508cace9541985438ba 100644 (file)
@@ -589,15 +589,6 @@ after_window_insert_text(GtkTextBuffer *textbuffer, GtkTextIter *location, gchar
 
         int chars_written = flush_text_buffer(win);
                event_throw(CHIMARA_GLK(gtk_widget_get_ancestor(win->widget, CHIMARA_TYPE_GLK)), evtype_LineInput, win, chars_written, 0);
-
-               ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
-               if(glk_data->unregister_arr) 
-               {
-            if(win->input_request_type == INPUT_REQUEST_LINE_UNICODE)
-                               (*glk_data->unregister_arr)(win->line_input_buffer_unicode, win->line_input_buffer_max_len, "&+#!Iu", win->buffer_rock);
-                       else
-                (*glk_data->unregister_arr)(win->line_input_buffer, win->line_input_buffer_max_len, "&+#!Cn", win->buffer_rock);
-        }
        }
 }
 
@@ -610,13 +601,5 @@ on_input_entry_activate(GtkEntry *input_entry, winid_t win)
 
        int chars_written = flush_text_grid(win);
        event_throw(CHIMARA_GLK(gtk_widget_get_ancestor(win->widget, CHIMARA_TYPE_GLK)), evtype_LineInput, win, chars_written, 0);
-       ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
-       if(glk_data->unregister_arr) 
-       {
-        if(win->input_request_type == INPUT_REQUEST_LINE_UNICODE)
-                       (*glk_data->unregister_arr)(win->line_input_buffer_unicode, win->line_input_buffer_max_len, "&+#!Iu", win->buffer_rock);
-               else
-            (*glk_data->unregister_arr)(win->line_input_buffer, win->line_input_buffer_max_len, "&+#!Cn", win->buffer_rock);
-    }
 }