Use init and clear for GMutex and GCond
authorPhilip Chimento <philip.chimento@gmail.com>
Wed, 21 Aug 2013 02:11:06 +0000 (19:11 -0700)
committerPhilip Chimento <philip.chimento@gmail.com>
Wed, 4 Sep 2013 02:39:14 +0000 (19:39 -0700)
- g_mutex_init() replaces g_mutex_new()
- g_mutex_clear() replaces g_mutex_free()
- g_cond_init() replaces g_cond_new()
- g_cond_clear() replaces g_cond_free()

The old functions were deprecated and the new functions were added as
of GLib 2.32.

This requires all structures to use GMutex members instead of GMutex *
pointers; likewise for GCond. Since we cannot set the GMutex * pointers
to NULL anymore when the ChimaraGlk widget is finalized, we add an
after_finalize flag that is set at the beginning of
chimara_glk_finalize().

libchimara/abort.c
libchimara/chimara-glk-private.h
libchimara/chimara-glk.c
libchimara/event.c
libchimara/glk.c
libchimara/graphics.c
libchimara/input.c
libchimara/window.c

index cec03a6a38cd84df1da4799762830a16500fafbe..26eb8c4d1c136a4c122ffb0ebaad2e738fe5b5bb 100644 (file)
@@ -58,13 +58,13 @@ void
 check_for_abort(void)
 {
        ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
 check_for_abort(void)
 {
        ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
-       g_mutex_lock(glk_data->abort_lock);
+       g_mutex_lock(&glk_data->abort_lock);
        if(glk_data->abort_signalled)
        {
        if(glk_data->abort_signalled)
        {
-               g_mutex_unlock(glk_data->abort_lock);
+               g_mutex_unlock(&glk_data->abort_lock);
                abort_glk();
        }
                abort_glk();
        }
-       g_mutex_unlock(glk_data->abort_lock);
+       g_mutex_unlock(&glk_data->abort_lock);
 }
 
 /* Internal function: shut down all requests and anything not necessary while
 }
 
 /* Internal function: shut down all requests and anything not necessary while
@@ -113,10 +113,10 @@ shutdown_glk_pre(void)
                ;
        
        /* Wait for any pending window rearrange */
                ;
        
        /* Wait for any pending window rearrange */
-       g_mutex_lock(glk_data->arrange_lock);
+       g_mutex_lock(&glk_data->arrange_lock);
        if(glk_data->needs_rearrange)
        if(glk_data->needs_rearrange)
-               g_cond_wait(glk_data->rearranged, glk_data->arrange_lock);
-       g_mutex_unlock(glk_data->arrange_lock);
+               g_cond_wait(&glk_data->rearranged, &glk_data->arrange_lock);
+       g_mutex_unlock(&glk_data->arrange_lock);
 }
 
 /* Internal function: do any Glk-thread cleanup for shutting down the Glk library. */
 }
 
 /* Internal function: do any Glk-thread cleanup for shutting down the Glk library. */
@@ -141,7 +141,7 @@ shutdown_glk_post(void)
                glk_schannel_destroy(sch);
        
        /* Empty the event queue */
                glk_schannel_destroy(sch);
        
        /* Empty the event queue */
-       g_mutex_lock(glk_data->event_lock);
+       g_mutex_lock(&glk_data->event_lock);
        g_queue_foreach(glk_data->event_queue, (GFunc)g_free, NULL);
 
        /* COMPAT: g_queue_clear could be used here, but only appeared in 2.14 */
        g_queue_foreach(glk_data->event_queue, (GFunc)g_free, NULL);
 
        /* COMPAT: g_queue_clear could be used here, but only appeared in 2.14 */
@@ -150,19 +150,19 @@ shutdown_glk_post(void)
        glk_data->event_queue->head = glk_data->event_queue->tail = NULL;
        glk_data->event_queue->length = 0;
 
        glk_data->event_queue->head = glk_data->event_queue->tail = NULL;
        glk_data->event_queue->length = 0;
 
-       g_mutex_unlock(glk_data->event_lock);
-       
+       g_mutex_unlock(&glk_data->event_lock);
+
        /* Reset the abort signaling mechanism */
        /* Reset the abort signaling mechanism */
-       g_mutex_lock(glk_data->abort_lock);
+       g_mutex_lock(&glk_data->abort_lock);
        glk_data->abort_signalled = FALSE;
        glk_data->abort_signalled = FALSE;
-       g_mutex_unlock(glk_data->abort_lock);
-       
+       g_mutex_unlock(&glk_data->abort_lock);
+
        /* Reset arrangement mechanism */
        /* Reset arrangement mechanism */
-       g_mutex_lock(glk_data->arrange_lock);
+       g_mutex_lock(&glk_data->arrange_lock);
        glk_data->needs_rearrange = FALSE;
        glk_data->ignore_next_arrange_event = FALSE;
        glk_data->needs_rearrange = FALSE;
        glk_data->ignore_next_arrange_event = FALSE;
-       g_mutex_unlock(glk_data->arrange_lock);
-       
+       g_mutex_unlock(&glk_data->arrange_lock);
+
        /* Unref input queues (they are not destroyed because the main thread stil holds a ref */
        g_async_queue_unref(glk_data->char_input_queue);
        g_async_queue_unref(glk_data->line_input_queue);
        /* Unref input queues (they are not destroyed because the main thread stil holds a ref */
        g_async_queue_unref(glk_data->char_input_queue);
        g_async_queue_unref(glk_data->line_input_queue);
index 01b4a256ddfdc731d7e0fd8ee8a99545a30dbb75..5a73939a8384748078f6c9375e504ac38c7c7c95 100644 (file)
@@ -38,33 +38,35 @@ struct _ChimaraGlkPrivate {
        /* *** Threading data *** */
        /* Whether program is running */
        gboolean running;
        /* *** Threading data *** */
        /* Whether program is running */
        gboolean running;
+       /* Whether widget has been finalized */
+       gboolean after_finalize;
     /* Glk program loaded in widget */
     GModule *program;
     /* Thread in which Glk program is run */
     GThread *thread;
     /* Event queue and threading stuff */
     GQueue *event_queue;
     /* Glk program loaded in widget */
     GModule *program;
     /* Thread in which Glk program is run */
     GThread *thread;
     /* Event queue and threading stuff */
     GQueue *event_queue;
-    GMutex *event_lock;
-    GCond *event_queue_not_empty;
-    GCond *event_queue_not_full;
+       GMutex event_lock;
+       GCond event_queue_not_empty;
+       GCond event_queue_not_full;
     /* Abort mechanism */
     /* Abort mechanism */
-    GMutex *abort_lock;
+       GMutex abort_lock;
     gboolean abort_signalled;
        /* Key press after shutdown mechanism */
     gboolean abort_signalled;
        /* Key press after shutdown mechanism */
-       GMutex *shutdown_lock;
-       GCond *shutdown_key_pressed;
+       GMutex shutdown_lock;
+       GCond shutdown_key_pressed;
        /* Window arrangement locks */
        /* Window arrangement locks */
-       GMutex *arrange_lock;
-       GCond *rearranged;
+       GMutex arrange_lock;
+       GCond rearranged;
        gboolean needs_rearrange;
        gboolean ignore_next_arrange_event;
        /* Input queues */
        GAsyncQueue *char_input_queue;
        GAsyncQueue *line_input_queue;
        /* Resource loading locks */
        gboolean needs_rearrange;
        gboolean ignore_next_arrange_event;
        /* Input queues */
        GAsyncQueue *char_input_queue;
        GAsyncQueue *line_input_queue;
        /* Resource loading locks */
-       GMutex *resource_lock;
-       GCond *resource_loaded;
-       GCond *resource_info_available;
+       GMutex resource_lock;
+       GCond resource_loaded;
+       GCond resource_info_available;
        guint32 resource_available;
 
        /* *** Glk library data *** */
        guint32 resource_available;
 
        /* *** Glk library data *** */
index 9d4f443d4f1e4c9f6925f25d1dc3dbee02ac9a43..b8926dcab94bea86d9619c9100b1747dc66714c0 100644 (file)
@@ -162,20 +162,22 @@ chimara_glk_init(ChimaraGlk *self)
        priv->glk_styles = g_new0(StyleSet,1);
        priv->final_message = g_strdup("[ The game has finished ]");
     priv->event_queue = g_queue_new();
        priv->glk_styles = g_new0(StyleSet,1);
        priv->final_message = g_strdup("[ The game has finished ]");
     priv->event_queue = g_queue_new();
-    priv->event_lock = g_mutex_new();
-    priv->event_queue_not_empty = g_cond_new();
-    priv->event_queue_not_full = g_cond_new();
-    priv->abort_lock = g_mutex_new();
-       priv->shutdown_lock = g_mutex_new();
-       priv->shutdown_key_pressed = g_cond_new();
-       priv->arrange_lock = g_mutex_new();
-       priv->rearranged = g_cond_new();
        priv->char_input_queue = g_async_queue_new();
        priv->line_input_queue = g_async_queue_new();
        /* FIXME Should be g_async_queue_new_full(g_free); but only in GTK >= 2.16 */
        priv->char_input_queue = g_async_queue_new();
        priv->line_input_queue = g_async_queue_new();
        /* FIXME Should be g_async_queue_new_full(g_free); but only in GTK >= 2.16 */
-       priv->resource_lock = g_mutex_new();
-       priv->resource_loaded = g_cond_new();
-       priv->resource_info_available = g_cond_new();
+
+       g_mutex_init(&priv->event_lock);
+       g_mutex_init(&priv->abort_lock);
+       g_mutex_init(&priv->shutdown_lock);
+       g_mutex_init(&priv->arrange_lock);
+       g_mutex_init(&priv->resource_lock);
+
+       g_cond_init(&priv->event_queue_not_empty);
+       g_cond_init(&priv->event_queue_not_full);
+       g_cond_init(&priv->shutdown_key_pressed);
+       g_cond_init(&priv->rearranged);
+       g_cond_init(&priv->resource_loaded);
+       g_cond_init(&priv->resource_info_available);
 
        style_init(self);
 }
 
        style_init(self);
 }
@@ -239,6 +241,7 @@ chimara_glk_finalize(GObject *object)
 {
     ChimaraGlk *self = CHIMARA_GLK(object);
        CHIMARA_GLK_USE_PRIVATE(self, priv);
 {
     ChimaraGlk *self = CHIMARA_GLK(object);
        CHIMARA_GLK_USE_PRIVATE(self, priv);
+       priv->after_finalize = TRUE;
 
        /* Free widget properties */
        g_free(priv->final_message);
 
        /* Free widget properties */
        g_free(priv->final_message);
@@ -249,36 +252,38 @@ chimara_glk_finalize(GObject *object)
        g_hash_table_destroy(priv->glk_styles->text_grid);
 
     /* Free the event queue */
        g_hash_table_destroy(priv->glk_styles->text_grid);
 
     /* Free the event queue */
-    g_mutex_lock(priv->event_lock);
+    g_mutex_lock(&priv->event_lock);
        g_queue_foreach(priv->event_queue, (GFunc)g_free, NULL);
        g_queue_free(priv->event_queue);
        g_queue_foreach(priv->event_queue, (GFunc)g_free, NULL);
        g_queue_free(priv->event_queue);
-       g_cond_free(priv->event_queue_not_empty);
-       g_cond_free(priv->event_queue_not_full);
+       g_cond_clear(&priv->event_queue_not_empty);
+       g_cond_clear(&priv->event_queue_not_full);
        priv->event_queue = NULL;
        priv->event_queue = NULL;
-       g_mutex_unlock(priv->event_lock);
-       g_mutex_free(priv->event_lock);
+       g_mutex_unlock(&priv->event_lock);
+       g_mutex_clear(&priv->event_lock);
+
     /* Free the abort signaling mechanism */
     /* Free the abort signaling mechanism */
-       g_mutex_lock(priv->abort_lock);
+       g_mutex_lock(&priv->abort_lock);
        /* Make sure no other thread is busy with this */
        /* Make sure no other thread is busy with this */
-       g_mutex_unlock(priv->abort_lock);
-       g_mutex_free(priv->abort_lock);
-       priv->abort_lock = NULL;
+       g_mutex_unlock(&priv->abort_lock);
+       g_mutex_clear(&priv->abort_lock);
+
        /* Free the shutdown keypress signaling mechanism */
        /* Free the shutdown keypress signaling mechanism */
-       g_mutex_lock(priv->shutdown_lock);
-       g_cond_free(priv->shutdown_key_pressed);
-       g_mutex_unlock(priv->shutdown_lock);
-       priv->shutdown_lock = NULL;
+       g_mutex_lock(&priv->shutdown_lock);
+       g_cond_clear(&priv->shutdown_key_pressed);
+       g_mutex_unlock(&priv->shutdown_lock);
+       g_mutex_clear(&priv->shutdown_lock);
+
        /* Free the window arrangement signaling */
        /* Free the window arrangement signaling */
-       g_mutex_lock(priv->arrange_lock);
-       g_cond_free(priv->rearranged);
-       g_mutex_unlock(priv->arrange_lock);
-       g_mutex_free(priv->arrange_lock);
-       priv->arrange_lock = NULL;
-       g_mutex_lock(priv->resource_lock);
-       g_cond_free(priv->resource_loaded);
-       g_cond_free(priv->resource_info_available);
-       g_mutex_unlock(priv->resource_lock);
-       g_mutex_free(priv->resource_lock);
+       g_mutex_lock(&priv->arrange_lock);
+       g_cond_clear(&priv->rearranged);
+       g_mutex_unlock(&priv->arrange_lock);
+       g_mutex_clear(&priv->arrange_lock);
+
+       g_mutex_lock(&priv->resource_lock);
+       g_cond_clear(&priv->resource_loaded);
+       g_cond_clear(&priv->resource_info_available);
+       g_mutex_unlock(&priv->resource_lock);
+       g_mutex_clear(&priv->resource_lock);
        g_slist_foreach(priv->image_cache, (GFunc)clear_image_cache, NULL);
        g_slist_free(priv->image_cache);
        /* Unref input queues (this should destroy them since any Glk thread has stopped by now */
        g_slist_foreach(priv->image_cache, (GFunc)clear_image_cache, NULL);
        g_slist_free(priv->image_cache);
        /* Unref input queues (this should destroy them since any Glk thread has stopped by now */
@@ -561,7 +566,7 @@ chimara_glk_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
 
                /* arrange points to a window that contains all text grid and graphics
                 windows which have been resized */
 
                /* arrange points to a window that contains all text grid and graphics
                 windows which have been resized */
-               g_mutex_lock(priv->arrange_lock);
+               g_mutex_lock(&priv->arrange_lock);
                if(!priv->ignore_next_arrange_event)
                {
                        if(arrange)
                if(!priv->ignore_next_arrange_event)
                {
                        if(arrange)
@@ -570,8 +575,8 @@ chimara_glk_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
                else
                        priv->ignore_next_arrange_event = FALSE;
                priv->needs_rearrange = FALSE;
                else
                        priv->ignore_next_arrange_event = FALSE;
                priv->needs_rearrange = FALSE;
-               g_cond_signal(priv->rearranged);
-               g_mutex_unlock(priv->arrange_lock);
+               g_cond_signal(&priv->rearranged);
+               g_mutex_unlock(&priv->arrange_lock);
        }
 }
 
        }
 }
 
@@ -1284,16 +1289,16 @@ chimara_glk_stop(ChimaraGlk *glk)
     if(!priv->running)
        return;
     
     if(!priv->running)
        return;
     
-       if(priv->abort_lock) {
-               g_mutex_lock(priv->abort_lock);
+       if(!priv->after_finalize) {
+               g_mutex_lock(&priv->abort_lock);
                priv->abort_signalled = TRUE;
                priv->abort_signalled = TRUE;
-               g_mutex_unlock(priv->abort_lock);
+               g_mutex_unlock(&priv->abort_lock);
                /* Stop blocking on the event queue condition */
                event_throw(glk, evtype_Abort, NULL, 0, 0);
                /* Stop blocking on the shutdown key press condition */
                /* Stop blocking on the event queue condition */
                event_throw(glk, evtype_Abort, NULL, 0, 0);
                /* Stop blocking on the shutdown key press condition */
-               g_mutex_lock(priv->shutdown_lock);
-               g_cond_signal(priv->shutdown_key_pressed);
-               g_mutex_unlock(priv->shutdown_lock);
+               g_mutex_lock(&priv->shutdown_lock);
+               g_cond_signal(&priv->shutdown_key_pressed);
+               g_mutex_unlock(&priv->shutdown_lock);
        }
 }
 
        }
 }
 
index 199a837eae0343d2958773380da3757466960990..7c916c073b5b8e4eef94b41dd387389f876c653c 100644 (file)
@@ -27,14 +27,14 @@ event_throw(ChimaraGlk *glk, glui32 type, winid_t win, glui32 val1, glui32 val2)
        g_get_current_time(&timeout);
        g_time_val_add(&timeout, EVENT_TIMEOUT_MICROSECONDS);
 
        g_get_current_time(&timeout);
        g_time_val_add(&timeout, EVENT_TIMEOUT_MICROSECONDS);
 
-       g_mutex_lock(priv->event_lock);
+       g_mutex_lock(&priv->event_lock);
 
        /* Wait for room in the event queue */
        while( g_queue_get_length(priv->event_queue) >= EVENT_QUEUE_MAX_LENGTH )
 
        /* Wait for room in the event queue */
        while( g_queue_get_length(priv->event_queue) >= EVENT_QUEUE_MAX_LENGTH )
-               if( !g_cond_timed_wait(priv->event_queue_not_full, priv->event_lock, &timeout) ) 
+               if( !g_cond_timed_wait(&priv->event_queue_not_full, &priv->event_lock, &timeout) ) 
                {
                        /* Drop the event after 3 seconds */
                {
                        /* Drop the event after 3 seconds */
-                       g_mutex_unlock(priv->event_lock);
+                       g_mutex_unlock(&priv->event_lock);
                        return;
                }
 
                        return;
                }
 
@@ -46,9 +46,9 @@ event_throw(ChimaraGlk *glk, glui32 type, winid_t win, glui32 val1, glui32 val2)
        g_queue_push_head(priv->event_queue, event);
 
        /* Signal that there is an event */
        g_queue_push_head(priv->event_queue, event);
 
        /* Signal that there is an event */
-       g_cond_signal(priv->event_queue_not_empty);
+       g_cond_signal(&priv->event_queue_not_empty);
 
 
-       g_mutex_unlock(priv->event_lock);
+       g_mutex_unlock(&priv->event_lock);
 }
 
 /* Helper function: Wait for an event in the event queue. If it is a forced
 }
 
 /* Helper function: Wait for an event in the event queue. If it is a forced
@@ -59,22 +59,22 @@ static void
 get_appropriate_event(event_t *event)
 {
        ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
 get_appropriate_event(event_t *event)
 {
        ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
-       
-       g_mutex_lock(glk_data->event_lock);
+
+       g_mutex_lock(&glk_data->event_lock);
 
        event_t *retrieved_event = NULL;
 
        /* Wait for an event */
        if( g_queue_is_empty(glk_data->event_queue) )
 
        event_t *retrieved_event = NULL;
 
        /* Wait for an event */
        if( g_queue_is_empty(glk_data->event_queue) )
-               g_cond_wait(glk_data->event_queue_not_empty, glk_data->event_lock);
+               g_cond_wait(&glk_data->event_queue_not_empty, &glk_data->event_lock);
 
        retrieved_event = g_queue_pop_tail(glk_data->event_queue);
 
        /* Signal that the event queue is no longer full */
 
        retrieved_event = g_queue_pop_tail(glk_data->event_queue);
 
        /* Signal that the event queue is no longer full */
-       g_cond_signal(glk_data->event_queue_not_full);
-       
-       g_mutex_unlock(glk_data->event_lock);
-       
+       g_cond_signal(&glk_data->event_queue_not_full);
+
+       g_mutex_unlock(&glk_data->event_lock);
+
        if(retrieved_event->type == evtype_ForcedCharInput)
        {
                /* Check for forced character input in the queue */
        if(retrieved_event->type == evtype_ForcedCharInput)
        {
                /* Check for forced character input in the queue */
@@ -90,10 +90,10 @@ get_appropriate_event(event_t *event)
                else
                {
                        get_appropriate_event(event);
                else
                {
                        get_appropriate_event(event);
-                       g_mutex_lock(glk_data->event_lock);
+                       g_mutex_lock(&glk_data->event_lock);
                        g_queue_push_tail(glk_data->event_queue, retrieved_event);
                        g_queue_push_tail(glk_data->event_queue, retrieved_event);
-                       g_cond_signal(glk_data->event_queue_not_empty);
-                       g_mutex_unlock(glk_data->event_lock);
+                       g_cond_signal(&glk_data->event_queue_not_empty);
+                       g_mutex_unlock(&glk_data->event_lock);
                }
        }
        else if(retrieved_event->type == evtype_ForcedLineInput)
                }
        }
        else if(retrieved_event->type == evtype_ForcedLineInput)
@@ -111,10 +111,10 @@ get_appropriate_event(event_t *event)
                else
                {
                        get_appropriate_event(event);
                else
                {
                        get_appropriate_event(event);
-                       g_mutex_lock(glk_data->event_lock);
+                       g_mutex_lock(&glk_data->event_lock);
                        g_queue_push_tail(glk_data->event_queue, retrieved_event);
                        g_queue_push_tail(glk_data->event_queue, retrieved_event);
-                       g_cond_signal(glk_data->event_queue_not_empty);
-                       g_mutex_unlock(glk_data->event_lock);
+                       g_cond_signal(&glk_data->event_queue_not_empty);
+                       g_mutex_unlock(&glk_data->event_lock);
                }
        }
        else
                }
        }
        else
@@ -242,9 +242,9 @@ glk_select_poll(event_t *event)
        event->win = NULL;
        event->val1 = 0;
        event->val2 = 0;
        event->win = NULL;
        event->val1 = 0;
        event->val2 = 0;
-       
-       g_mutex_lock(glk_data->event_lock);
-       
+
+       g_mutex_lock(&glk_data->event_lock);
+
        if( !g_queue_is_empty(glk_data->event_queue) )
        {
                GList *link;
        if( !g_queue_is_empty(glk_data->event_queue) )
        {
                GList *link;
@@ -257,14 +257,14 @@ glk_select_poll(event_t *event)
                                memcpy(event, link->data, sizeof(event_t));
                                g_free(link->data);
                                g_queue_delete_link(glk_data->event_queue, link);
                                memcpy(event, link->data, sizeof(event_t));
                                g_free(link->data);
                                g_queue_delete_link(glk_data->event_queue, link);
-                               g_cond_signal(glk_data->event_queue_not_full);
+                               g_cond_signal(&glk_data->event_queue_not_full);
                                break;
                        }
                }
        }
                                break;
                        }
                }
        }
-       
-       g_mutex_unlock(glk_data->event_lock);
-       
+
+       g_mutex_unlock(&glk_data->event_lock);
+
        /* Check for interrupt */
        glk_tick();
 
        /* Check for interrupt */
        glk_tick();
 
index f5df12ee4cc80c7fd88dd055bb11f91f52f6085f..b86daed07971769f49f861c460f4ea8836b79258 100644 (file)
@@ -74,15 +74,15 @@ glk_exit(void)
                glk_put_string("\n");
                flush_window_buffer(largewin);
        }
                glk_put_string("\n");
                flush_window_buffer(largewin);
        }
-       
-       g_mutex_lock(glk_data->shutdown_lock);
+
+       g_mutex_lock(&glk_data->shutdown_lock);
        for(win = glk_window_iterate(NULL, NULL); win; win = glk_window_iterate(win, NULL)) {
                if(win->type == wintype_TextGrid || win->type == wintype_TextBuffer)
                        g_signal_handler_unblock(win->widget, win->shutdown_keypress_handler);
        }
        for(win = glk_window_iterate(NULL, NULL); win; win = glk_window_iterate(win, NULL)) {
                if(win->type == wintype_TextGrid || win->type == wintype_TextBuffer)
                        g_signal_handler_unblock(win->widget, win->shutdown_keypress_handler);
        }
-       g_cond_wait(glk_data->shutdown_key_pressed, glk_data->shutdown_lock);
-       g_mutex_unlock(glk_data->shutdown_lock);
-       
+       g_cond_wait(&glk_data->shutdown_key_pressed, &glk_data->shutdown_lock);
+       g_mutex_unlock(&glk_data->shutdown_lock);
+
        shutdown_glk_post();
 
        g_signal_emit_by_name(glk_data->self, "stopped");
        shutdown_glk_post();
 
        g_signal_emit_by_name(glk_data->self, "stopped");
index 543ad43563b147a6ecd5ed0f3e0e9cdbe3f443d0..f83ec0eb2001df91878fc52d5d9da7c1377fb6a0 100644 (file)
@@ -56,11 +56,11 @@ load_image_from_blorb(giblorb_result_t resource, glui32 image, gint width, gint
        g_free(buffer);
 
        /* Wait for the PixbufLoader to finish loading the image */
        g_free(buffer);
 
        /* Wait for the PixbufLoader to finish loading the image */
-       g_mutex_lock(glk_data->resource_lock);
+       g_mutex_lock(&glk_data->resource_lock);
        while(!image_loaded) {
        while(!image_loaded) {
-               g_cond_wait(glk_data->resource_loaded, glk_data->resource_lock);
+               g_cond_wait(&glk_data->resource_loaded, &glk_data->resource_lock);
        }
        }
-       g_mutex_unlock(glk_data->resource_lock);
+       g_mutex_unlock(&glk_data->resource_lock);
 
        info->pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
        g_object_ref(info->pixbuf);
 
        info->pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
        g_object_ref(info->pixbuf);
@@ -148,12 +148,12 @@ on_size_prepared(GdkPixbufLoader *loader, gint width, gint height, struct image_
 {
        ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
 
 {
        ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
 
-       g_mutex_lock(glk_data->resource_lock);
+       g_mutex_lock(&glk_data->resource_lock);
        info->width = width;
        info->height = height;
        size_determined = TRUE;
        info->width = width;
        info->height = height;
        size_determined = TRUE;
-       g_cond_broadcast(glk_data->resource_info_available);
-       g_mutex_unlock(glk_data->resource_lock);
+       g_cond_broadcast(&glk_data->resource_info_available);
+       g_mutex_unlock(&glk_data->resource_lock);
 }
 
 void
 }
 
 void
@@ -163,10 +163,10 @@ on_pixbuf_closed(GdkPixbufLoader *loader, gpointer data)
 
        ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
 
 
        ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
 
-       g_mutex_lock(glk_data->resource_lock);
+       g_mutex_lock(&glk_data->resource_lock);
        image_loaded = TRUE;
        image_loaded = TRUE;
-       g_cond_broadcast(glk_data->resource_loaded);
-       g_mutex_unlock(glk_data->resource_lock);
+       g_cond_broadcast(&glk_data->resource_loaded);
+       g_mutex_unlock(&glk_data->resource_lock);
 
        gdk_threads_leave();
 }
 
        gdk_threads_leave();
 }
index fd5aef4e5189836034199637e2e4c16951956e04..c54fe8bf68f4ba1802687d5c3fc0c6a0aedc3f1f 100644 (file)
@@ -441,10 +441,10 @@ on_shutdown_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win)
                g_node_traverse(priv->root_window, G_IN_ORDER, G_TRAVERSE_LEAVES, -1, (GNodeTraverseFunc)turn_off_handler, NULL);
        
        /* Signal the Glk library that it can shut everything down now */
                g_node_traverse(priv->root_window, G_IN_ORDER, G_TRAVERSE_LEAVES, -1, (GNodeTraverseFunc)turn_off_handler, NULL);
        
        /* Signal the Glk library that it can shut everything down now */
-       g_mutex_lock(priv->shutdown_lock);
-       g_cond_signal(priv->shutdown_key_pressed);
-       g_mutex_unlock(priv->shutdown_lock);
-       
+       g_mutex_lock(&priv->shutdown_lock);
+       g_cond_signal(&priv->shutdown_key_pressed);
+       g_mutex_unlock(&priv->shutdown_lock);
+
        return TRUE; /* block the event */
 }
 
        return TRUE; /* block the event */
 }
 
index c9132939237d5548f9632ff85a903f0e70148088..bcdce5535bc96125133cb4b9e7fbe78b20b4bc87 100644 (file)
@@ -691,10 +691,10 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype,
        }
 
        /* Set the window as a child of the Glk widget, don't trigger an arrange event */
        }
 
        /* Set the window as a child of the Glk widget, don't trigger an arrange event */
-       g_mutex_lock(glk_data->arrange_lock);
+       g_mutex_lock(&glk_data->arrange_lock);
        glk_data->needs_rearrange = TRUE;
        glk_data->ignore_next_arrange_event = TRUE;
        glk_data->needs_rearrange = TRUE;
        glk_data->ignore_next_arrange_event = TRUE;
-       g_mutex_unlock(glk_data->arrange_lock);
+       g_mutex_unlock(&glk_data->arrange_lock);
        gtk_widget_set_parent(win->frame, GTK_WIDGET(glk_data->self));
        gtk_widget_queue_resize(GTK_WIDGET(glk_data->self));
        
        gtk_widget_set_parent(win->frame, GTK_WIDGET(glk_data->self));
        gtk_widget_queue_resize(GTK_WIDGET(glk_data->self));
        
@@ -888,10 +888,10 @@ glk_window_close(winid_t win, stream_result_t *result)
        window_close_common(win, FALSE);
 
        /* Schedule a redraw */
        window_close_common(win, FALSE);
 
        /* Schedule a redraw */
-       g_mutex_lock(glk_data->arrange_lock);
+       g_mutex_lock(&glk_data->arrange_lock);
        glk_data->needs_rearrange = TRUE;
        glk_data->ignore_next_arrange_event = TRUE;
        glk_data->needs_rearrange = TRUE;
        glk_data->ignore_next_arrange_event = TRUE;
-       g_mutex_unlock(glk_data->arrange_lock);
+       g_mutex_unlock(&glk_data->arrange_lock);
        gtk_widget_queue_resize( GTK_WIDGET(glk_data->self) );
        gdk_threads_leave();
 }
        gtk_widget_queue_resize( GTK_WIDGET(glk_data->self) );
        gdk_threads_leave();
 }
@@ -954,11 +954,11 @@ glk_window_clear(winid_t win)
                    /* fill the buffer with blanks */
                {
                        /* Wait for the window's size to be updated */
                    /* fill the buffer with blanks */
                {
                        /* Wait for the window's size to be updated */
-                       g_mutex_lock(glk_data->arrange_lock);
+                       g_mutex_lock(&glk_data->arrange_lock);
                        if(glk_data->needs_rearrange)
                        if(glk_data->needs_rearrange)
-                               g_cond_wait(glk_data->rearranged, glk_data->arrange_lock);
-                       g_mutex_unlock(glk_data->arrange_lock);
-                       
+                               g_cond_wait(&glk_data->rearranged, &glk_data->arrange_lock);
+                       g_mutex_unlock(&glk_data->arrange_lock);
+
                    gdk_threads_enter();
                    
             /* Manually put newlines at the end of each row of characters in the buffer; manual newlines make resizing the window's grid easier. */
                    gdk_threads_enter();
                    
             /* Manually put newlines at the end of each row of characters in the buffer; manual newlines make resizing the window's grid easier. */
@@ -1006,10 +1006,10 @@ glk_window_clear(winid_t win)
                        GtkAllocation allocation;
 
                        /* Wait for the window's size to be updated */
                        GtkAllocation allocation;
 
                        /* Wait for the window's size to be updated */
-                       g_mutex_lock(glk_data->arrange_lock);
+                       g_mutex_lock(&glk_data->arrange_lock);
                        if(glk_data->needs_rearrange)
                        if(glk_data->needs_rearrange)
-                               g_cond_wait(glk_data->rearranged, glk_data->arrange_lock);
-                       g_mutex_unlock(glk_data->arrange_lock);
+                               g_cond_wait(&glk_data->rearranged, &glk_data->arrange_lock);
+                       g_mutex_unlock(&glk_data->arrange_lock);
 
                        gdk_threads_enter();
                        gtk_widget_get_allocation(win->widget, &allocation);
 
                        gdk_threads_enter();
                        gtk_widget_get_allocation(win->widget, &allocation);
@@ -1150,11 +1150,11 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr)
             
         case wintype_TextGrid:
                        /* Wait until the window's size is current */
             
         case wintype_TextGrid:
                        /* Wait until the window's size is current */
-                       g_mutex_lock(glk_data->arrange_lock);
+                       g_mutex_lock(&glk_data->arrange_lock);
                        if(glk_data->needs_rearrange)
                        if(glk_data->needs_rearrange)
-                               g_cond_wait(glk_data->rearranged, glk_data->arrange_lock);
-                       g_mutex_unlock(glk_data->arrange_lock);
-                       
+                               g_cond_wait(&glk_data->rearranged, &glk_data->arrange_lock);
+                       g_mutex_unlock(&glk_data->arrange_lock);
+
                        gdk_threads_enter();
                        gtk_widget_get_allocation(win->widget, &allocation);
                        /* Cache the width and height */
                        gdk_threads_enter();
                        gtk_widget_get_allocation(win->widget, &allocation);
                        /* Cache the width and height */
@@ -1169,12 +1169,12 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr)
             break;
             
         case wintype_TextBuffer:
             break;
             
         case wintype_TextBuffer:
-            /* Wait until the window's size is current */
-                       g_mutex_lock(glk_data->arrange_lock);
+                       /* Wait until the window's size is current */
+                       g_mutex_lock(&glk_data->arrange_lock);
                        if(glk_data->needs_rearrange)
                        if(glk_data->needs_rearrange)
-                               g_cond_wait(glk_data->rearranged, glk_data->arrange_lock);
-                       g_mutex_unlock(glk_data->arrange_lock);
-                       
+                               g_cond_wait(&glk_data->rearranged, &glk_data->arrange_lock);
+                       g_mutex_unlock(&glk_data->arrange_lock);
+
             gdk_threads_enter();
             gtk_widget_get_allocation(win->widget, &allocation);
             if(widthptr != NULL)
             gdk_threads_enter();
             gtk_widget_get_allocation(win->widget, &allocation);
             if(widthptr != NULL)
@@ -1186,11 +1186,11 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr)
             break;
 
                case wintype_Graphics:
             break;
 
                case wintype_Graphics:
-                       g_mutex_lock(glk_data->arrange_lock);
+                       g_mutex_lock(&glk_data->arrange_lock);
                        if(glk_data->needs_rearrange)
                        if(glk_data->needs_rearrange)
-                               g_cond_wait(glk_data->rearranged, glk_data->arrange_lock);
-                       g_mutex_unlock(glk_data->arrange_lock);
-                       
+                               g_cond_wait(&glk_data->rearranged, &glk_data->arrange_lock);
+                       g_mutex_unlock(&glk_data->arrange_lock);
+
             gdk_threads_enter();
             gtk_widget_get_allocation(win->widget, &allocation);
             if(widthptr != NULL)
             gdk_threads_enter();
             gtk_widget_get_allocation(win->widget, &allocation);
             if(widthptr != NULL)
@@ -1293,10 +1293,10 @@ glk_window_set_arrangement(winid_t win, glui32 method, glui32 size, winid_t keyw
 
        /* Tell GTK to rearrange the windows */
        gdk_threads_enter();
 
        /* Tell GTK to rearrange the windows */
        gdk_threads_enter();
-       g_mutex_lock(glk_data->arrange_lock);
+       g_mutex_lock(&glk_data->arrange_lock);
        glk_data->needs_rearrange = TRUE;
        glk_data->ignore_next_arrange_event = TRUE;
        glk_data->needs_rearrange = TRUE;
        glk_data->ignore_next_arrange_event = TRUE;
-       g_mutex_unlock(glk_data->arrange_lock);
+       g_mutex_unlock(&glk_data->arrange_lock);
        gtk_widget_queue_resize(GTK_WIDGET(glk_data->self));
        gdk_threads_leave();
 }
        gtk_widget_queue_resize(GTK_WIDGET(glk_data->self));
        gdk_threads_leave();
 }
@@ -1365,10 +1365,10 @@ glk_window_move_cursor(winid_t win, glui32 xpos, glui32 ypos)
        ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
        
        /* Wait until the window's size is current */
        ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
        
        /* Wait until the window's size is current */
-       g_mutex_lock(glk_data->arrange_lock);
+       g_mutex_lock(&glk_data->arrange_lock);
        if(glk_data->needs_rearrange)
        if(glk_data->needs_rearrange)
-               g_cond_wait(glk_data->rearranged, glk_data->arrange_lock);
-       g_mutex_unlock(glk_data->arrange_lock);
+               g_cond_wait(&glk_data->rearranged, &glk_data->arrange_lock);
+       g_mutex_unlock(&glk_data->arrange_lock);
 
        /* Don't do anything if the window is shrunk down to nothing */
        if(win->width == 0 || win->height == 0)
 
        /* Don't do anything if the window is shrunk down to nothing */
        if(win->width == 0 || win->height == 0)