From: Philip Chimento Date: Wed, 21 Aug 2013 02:11:06 +0000 (-0700) Subject: Use init and clear for GMutex and GCond X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=e4a75256e901a89729c48fcc2f9229cd0cfe9124;p=projects%2Fchimara%2Fchimara.git Use init and clear for GMutex and GCond - 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(). --- diff --git a/libchimara/abort.c b/libchimara/abort.c index cec03a6..26eb8c4 100644 --- a/libchimara/abort.c +++ b/libchimara/abort.c @@ -58,13 +58,13 @@ void 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) { - g_mutex_unlock(glk_data->abort_lock); + g_mutex_unlock(&glk_data->abort_lock); 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 @@ -113,10 +113,10 @@ shutdown_glk_pre(void) ; /* 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) - 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. */ @@ -141,7 +141,7 @@ shutdown_glk_post(void) 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 */ @@ -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; - g_mutex_unlock(glk_data->event_lock); - + g_mutex_unlock(&glk_data->event_lock); + /* Reset the abort signaling mechanism */ - g_mutex_lock(glk_data->abort_lock); + g_mutex_lock(&glk_data->abort_lock); glk_data->abort_signalled = FALSE; - g_mutex_unlock(glk_data->abort_lock); - + g_mutex_unlock(&glk_data->abort_lock); + /* 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; - 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); diff --git a/libchimara/chimara-glk-private.h b/libchimara/chimara-glk-private.h index 01b4a25..5a73939 100644 --- a/libchimara/chimara-glk-private.h +++ b/libchimara/chimara-glk-private.h @@ -38,33 +38,35 @@ struct _ChimaraGlkPrivate { /* *** 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; - 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 */ - GMutex *abort_lock; + GMutex abort_lock; 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 */ - 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 */ - 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 *** */ diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index 5844017..337cfa5 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -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->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->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); } @@ -239,6 +241,7 @@ chimara_glk_finalize(GObject *object) { ChimaraGlk *self = CHIMARA_GLK(object); CHIMARA_GLK_USE_PRIVATE(self, priv); + priv->after_finalize = TRUE; /* 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_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_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; - 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 */ - g_mutex_lock(priv->abort_lock); + g_mutex_lock(&priv->abort_lock); /* 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 */ - 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 */ - 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 */ @@ -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 */ - g_mutex_lock(priv->arrange_lock); + g_mutex_lock(&priv->arrange_lock); 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; - g_cond_signal(priv->rearranged); - g_mutex_unlock(priv->arrange_lock); + g_cond_signal(&priv->rearranged); + g_mutex_unlock(&priv->arrange_lock); } } @@ -1285,16 +1290,16 @@ chimara_glk_stop(ChimaraGlk *glk) 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; - 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 */ - 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); } } diff --git a/libchimara/event.c b/libchimara/event.c index 199a837..7c916c0 100644 --- a/libchimara/event.c +++ b/libchimara/event.c @@ -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_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 ) - 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 */ - g_mutex_unlock(priv->event_lock); + g_mutex_unlock(&priv->event_lock); 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_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 @@ -59,22 +59,22 @@ static void 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) ) - 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 */ - 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 */ @@ -90,10 +90,10 @@ get_appropriate_event(event_t *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_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) @@ -111,10 +111,10 @@ get_appropriate_event(event_t *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_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 @@ -242,9 +242,9 @@ glk_select_poll(event_t *event) 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; @@ -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); - g_cond_signal(glk_data->event_queue_not_full); + g_cond_signal(&glk_data->event_queue_not_full); break; } } } - - g_mutex_unlock(glk_data->event_lock); - + + g_mutex_unlock(&glk_data->event_lock); + /* Check for interrupt */ glk_tick(); diff --git a/libchimara/glk.c b/libchimara/glk.c index f5df12e..b86daed 100644 --- a/libchimara/glk.c +++ b/libchimara/glk.c @@ -74,15 +74,15 @@ glk_exit(void) 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); } - 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"); diff --git a/libchimara/graphics.c b/libchimara/graphics.c index 543ad43..f83ec0e 100644 --- a/libchimara/graphics.c +++ b/libchimara/graphics.c @@ -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_mutex_lock(glk_data->resource_lock); + g_mutex_lock(&glk_data->resource_lock); 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); @@ -148,12 +148,12 @@ on_size_prepared(GdkPixbufLoader *loader, gint width, gint height, struct image_ { 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; - 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 @@ -163,10 +163,10 @@ on_pixbuf_closed(GdkPixbufLoader *loader, gpointer data) 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; - 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(); } diff --git a/libchimara/input.c b/libchimara/input.c index fd5aef4..c54fe8b 100644 --- a/libchimara/input.c +++ b/libchimara/input.c @@ -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_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 */ } diff --git a/libchimara/window.c b/libchimara/window.c index c913293..bcdce55 100644 --- a/libchimara/window.c +++ b/libchimara/window.c @@ -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 */ - 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; - 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)); @@ -888,10 +888,10 @@ glk_window_close(winid_t win, stream_result_t *result) 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; - 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(); } @@ -954,11 +954,11 @@ glk_window_clear(winid_t win) /* 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) - 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. */ @@ -1006,10 +1006,10 @@ glk_window_clear(winid_t win) 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) - 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); @@ -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 */ - g_mutex_lock(glk_data->arrange_lock); + g_mutex_lock(&glk_data->arrange_lock); 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 */ @@ -1169,12 +1169,12 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) 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) - 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) @@ -1186,11 +1186,11 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) break; case wintype_Graphics: - g_mutex_lock(glk_data->arrange_lock); + g_mutex_lock(&glk_data->arrange_lock); 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) @@ -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(); - 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; - 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(); } @@ -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 */ - g_mutex_lock(glk_data->arrange_lock); + g_mutex_lock(&glk_data->arrange_lock); 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)