Added test case for crash in ChimaraIF::command
authorP. F. Chimento <philip.chimento@gmail.com>
Fri, 19 Nov 2010 21:55:32 +0000 (22:55 +0100)
committerP. F. Chimento <philip.chimento@gmail.com>
Fri, 19 Nov 2010 21:55:32 +0000 (22:55 +0100)
There is a gdk_threads_enter/leave missing somewhere, because using GTK
calls from the signal handler of the ChimaraIF::command signal causes an
X error.

tests/test-close.c

index ddc291928e3a1f41129073f0087195df26e9389f..fc302034685695b43e0e2a776d34c250a5276365 100644 (file)
@@ -1,6 +1,18 @@
 #include <gtk/gtk.h>
 #include <libchimara/chimara-if.h>
 
+void
+on_command(ChimaraIF *glk, gchar *input, gchar *response, GtkWindow *window)
+{
+       GtkWidget *dialog = gtk_message_dialog_new(window, 
+               GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
+               "%s", input);
+       gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", 
+               response);
+       gtk_dialog_run(GTK_DIALOG(dialog));
+       gtk_widget_destroy(dialog);
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -15,8 +27,10 @@ main(int argc, char *argv[])
     /* Construct the window and its contents. We quit the GTK main loop
      * when the window's close button is clicked. */
     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_window_set_default_size(GTK_WINDOW(window), 400, 400);
     g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
-    glk = chimara_glk_new();
+    glk = chimara_if_new();
+    g_signal_connect(glk, "command", G_CALLBACK(on_command), window);
     gtk_container_add(GTK_CONTAINER(window), glk);
     gtk_widget_show_all(window);
     
@@ -24,6 +38,9 @@ main(int argc, char *argv[])
     around after gtk_main() exits */
     g_object_ref(glk);
     
+    /* Start the plugin */
+    g_assert(chimara_if_run_game(CHIMARA_IF(glk), "unicodetest.ulx", NULL));
+    
     /* Start the GTK main loop */
     gdk_threads_enter();
     gtk_main();