From 7be1d57200e9672910ae0cef74ee0074e171dbf1 Mon Sep 17 00:00:00 2001 From: Joshua Judson Rosen Date: Sun, 26 Mar 2017 22:24:41 -0400 Subject: Invert GTK+/guile thread relationship Making the GTK+ thread the main thread, and subordinating the guile thread, lets the GUI continue to live after the robot has died-- which means that we'll be able to switch to just doing everything in the GUI without requiring a separate xterm to see the final stats after the robot dies. --- src/ui-window.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/ui-window.c') diff --git a/src/ui-window.c b/src/ui-window.c index fb6f2ed..e923c24 100644 --- a/src/ui-window.c +++ b/src/ui-window.c @@ -56,16 +56,21 @@ static void ui_window_init(UIWindow *window) gtk_window_set_title(GTK_WINDOW(window), "GNU Robots"); gtk_window_set_resizable(GTK_WINDOW(window), FALSE); + + window->priv->cmdwin = ui_cmdwin_new(); + window->priv->arena = ui_arena_new(); } -void ui_window_postinit(UIWindow *window, Map* map) +void ui_window_postinit(UIWindow *window, Map* volatile* map) { GtkWidget *vbox; vbox = gtk_vbox_new(FALSE, 2); - window->priv->cmdwin = ui_cmdwin_new(); - window->priv->arena = ui_arena_new(); - ui_arena_set_map(UI_ARENA(window->priv->arena), map); + + while(!*map); /* wait for map object creation by guile thread */ + + /* ... because we need guile to load the map before we do this: */ + ui_arena_set_map(UI_ARENA(window->priv->arena), *map); /* TODO: Add menu first etc */ gtk_box_pack_start(GTK_BOX(vbox), window->priv->arena, TRUE, TRUE, 0); -- cgit v1.1