[java-atk-wrapper] Fix g_mutex and g_cond update syntax
- From: Magdalen Berns <mberns src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [java-atk-wrapper] Fix g_mutex and g_cond update syntax
- Date: Thu, 1 Jan 2015 23:37:14 +0000 (UTC)
commit e769736868ab8b713c7e215f2c4811cfa43952f8
Author: Magdalen Berns <m berns thismagpie com>
Date: Thu Jan 1 23:35:22 2015 +0000
Fix g_mutex and g_cond update syntax
It seems like the update was not implemented properly. Correcting
syntax should address this issue
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=742157
jni/src/AtkWrapper.c | 55 +++++++++++++++++++++++--------------------------
jni/src/jawimpl.c | 33 +++++++++++------------------
2 files changed, 39 insertions(+), 49 deletions(-)
---
diff --git a/jni/src/AtkWrapper.c b/jni/src/AtkWrapper.c
index c885f0d..08080fc 100644
--- a/jni/src/AtkWrapper.c
+++ b/jni/src/AtkWrapper.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <glib.h>
#include <gmodule.h>
+#include <atk-bridge.h>
#include <gdk/gdk.h>
#include <X11/Xlib.h>
#include <gconf/gconf-client.h>
@@ -49,22 +50,16 @@ struct _DummyDispatch
gboolean jaw_debug = FALSE;
-GMutex *atk_bridge_mutex = NULL;
-GCond *atk_bridge_cond = NULL;
+static GMutex atk_bridge_mutex;
+static GCond atk_bridge_cond;
+static GMutex key_dispatch_mutex;
+static GCond key_dispatch_cond;
-GMutex *key_dispatch_mutex = NULL;
-GCond *key_dispatch_cond = NULL;
static gint key_dispatch_result = KEY_DISPATCH_NOT_DISPATCHED;
static gboolean (*origin_g_idle_dispatch) (GSource*, GSourceFunc, gpointer);
static GModule* module_atk_bridge = NULL;
-typedef struct {
- GMutex jg_mutex;
-} JGMutex;
-
-JGMutex *jmutex;
-
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *javaVM, void *reserve)
{
JNIEnv *env;
@@ -116,7 +111,7 @@ static void jaw_exit_func ()
static gboolean
jaw_load_atk_bridge (gpointer p)
{
- g_mutex_lock(atk_bridge_mutex);
+ g_mutex_lock(&atk_bridge_mutex);
GVoidFunc dl_init;
if (!g_module_symbol(module_atk_bridge,
@@ -134,8 +129,8 @@ jaw_load_atk_bridge (gpointer p)
printf("ATK Bridge has been loaded successfully\n");
}
- g_cond_signal(atk_bridge_cond);
- g_mutex_unlock(atk_bridge_mutex);
+ g_cond_signal(&atk_bridge_cond);
+ g_mutex_unlock(&atk_bridge_mutex);
return FALSE;
}
@@ -177,19 +172,21 @@ JNICALL Java_org_GNOME_Accessibility_AtkWrapper_initNativeLibrary(JNIEnv *jniEnv
XInitThreads();
return JNI_FALSE;
}
+
+ jaw_impl_init_mutex();
+
+ g_mutex_init(&atk_bridge_mutex);
+ g_cond_init(&atk_bridge_cond);
+
+ g_mutex_init(&key_dispatch_mutex);
+ g_cond_init(&key_dispatch_cond);
+
atk_bridge_adaptor_init(NULL,NULL);
if (g_getenv ("AT_SPI_DEBUG"))
{
g_print ("Atk Accessibility bridge initialized\n");
}
- jaw_impl_init_mutex();
-
- jmutex = g_new(JGMutex, 1);
- g_mutex_init (&jmutex->jg_mutex);
-
- g_cond_init(cond);
-
// Dummy idle function for jaw_idle_dispatch to get
// the address of gdk_threads_dispatch
gdk_threads_add_idle(jaw_dummy_idle_func, NULL);
@@ -211,15 +208,15 @@ JNICALL Java_org_GNOME_Accessibility_AtkWrapper_loadAtkBridge(JNIEnv *jniEnv,
// We need to wait for the completion of the loading of ATK Bridge
// in order to ensure event listeners in ATK Bridge are properly
// registered before any emission of AWT event.
- g_mutex_lock(atk_bridge_mutex);
+ g_mutex_lock(&atk_bridge_mutex);
GThread *main_loop_thread = g_thread_create(jni_main_loop,
(gpointer)main_loop,
FALSE,
NULL);
- g_cond_wait(atk_bridge_cond, atk_bridge_mutex);
- g_mutex_unlock(atk_bridge_mutex);
+ g_cond_wait(&atk_bridge_cond, &atk_bridge_mutex);
+ g_mutex_unlock(&atk_bridge_mutex);
}
typedef enum _SignalType {
@@ -1045,7 +1042,7 @@ JNICALL Java_org_GNOME_Accessibility_AtkWrapper_componentRemoved(JNIEnv *jniEnv,
static gboolean
key_dispatch_handler (gpointer p)
{
- g_mutex_lock(key_dispatch_mutex);
+ g_mutex_lock(&key_dispatch_mutex);
jobject jAtkKeyEvent = (jobject)p;
JNIEnv *jniEnv = jaw_util_get_jni_env();
@@ -1126,8 +1123,8 @@ key_dispatch_handler (gpointer p)
(*jniEnv)->DeleteGlobalRef(jniEnv, jAtkKeyEvent);
- g_cond_signal(key_dispatch_cond);
- g_mutex_unlock(key_dispatch_mutex);
+ g_cond_signal(&key_dispatch_cond);
+ g_mutex_unlock(&key_dispatch_mutex);
return FALSE;
}
@@ -1140,12 +1137,12 @@ JNICALL Java_org_GNOME_Accessibility_AtkWrapper_dispatchKeyEvent(JNIEnv *jniEnv,
jboolean key_consumed;
jobject global_key_event = (*jniEnv)->NewGlobalRef(jniEnv, jAtkKeyEvent);
- g_mutex_lock(key_dispatch_mutex);
+ g_mutex_lock(&key_dispatch_mutex);
g_idle_add(key_dispatch_handler, (gpointer)global_key_event);
while (key_dispatch_result == KEY_DISPATCH_NOT_DISPATCHED) {
- g_cond_wait(key_dispatch_cond, key_dispatch_mutex);
+ g_cond_wait(&key_dispatch_cond, &key_dispatch_mutex);
}
if (key_dispatch_result == KEY_DISPATCH_CONSUMED)
@@ -1158,7 +1155,7 @@ JNICALL Java_org_GNOME_Accessibility_AtkWrapper_dispatchKeyEvent(JNIEnv *jniEnv,
key_dispatch_result = KEY_DISPATCH_NOT_DISPATCHED;
- g_mutex_unlock(key_dispatch_mutex);
+ g_mutex_unlock(&key_dispatch_mutex);
return key_consumed;
}
diff --git a/jni/src/jawimpl.c b/jni/src/jawimpl.c
index 9a40615..0466291 100644
--- a/jni/src/jawimpl.c
+++ b/jni/src/jawimpl.c
@@ -82,19 +82,12 @@ static gpointer jaw_impl_parent_class = NULL;
static GHashTable *typeTable = NULL;
static GHashTable *objectTable = NULL;
-static GMutex *objectTableMutex = NULL;
-
-typedef struct {
- GMutex jg_mutex;
-} JGMutex;
-
-JGMutex *jmutex;
+static GMutex objectTableMutex;
void
jaw_impl_init_mutex ()
{
- jmutex = g_new(JGMutex, 1);
- g_mutex_init (&jmutex->jg_mutex);
+ g_mutex_init(&objectTableMutex);
}
static void
@@ -108,9 +101,9 @@ object_table_insert (JNIEnv *jniEnv, jobject ac, JawImpl * jaw_impl)
"()I");
gint hash_key = (gint)(*jniEnv)->CallIntMethod(jniEnv, ac, jmid);
- g_mutex_lock(objectTableMutex);
+ g_mutex_lock(&objectTableMutex);
g_hash_table_insert(objectTable, (gpointer)&hash_key, (gpointer)jaw_impl);
- g_mutex_unlock(objectTableMutex);
+ g_mutex_unlock(&objectTableMutex);
}
static JawImpl*
@@ -125,9 +118,9 @@ object_table_lookup (JNIEnv *jniEnv, jobject ac)
gint hash_key = (gint)(*jniEnv)->CallIntMethod( jniEnv, ac, jmid );
gpointer value = NULL;
- g_mutex_lock(objectTableMutex);
+ g_mutex_lock(&objectTableMutex);
value = g_hash_table_lookup(objectTable, (gpointer)&hash_key);
- g_mutex_unlock(objectTableMutex);
+ g_mutex_unlock(&objectTableMutex);
return (JawImpl*)value;
}
@@ -143,9 +136,9 @@ object_table_remove(JNIEnv *jniEnv, jobject ac)
"()I" );
gint hash_key = (gint)(*jniEnv)->CallIntMethod( jniEnv, ac, jmid );
- g_mutex_lock(objectTableMutex);
+ g_mutex_lock(&objectTableMutex);
g_hash_table_remove( objectTable, (gpointer)&hash_key );
- g_mutex_unlock(objectTableMutex);
+ g_mutex_unlock(&objectTableMutex);
}
static void
@@ -252,12 +245,12 @@ jaw_impl_get_instance (JNIEnv *jniEnv, jobject ac)
{
JawImpl *jaw_impl;
- g_mutex_lock(objectTableMutex);
+ g_mutex_lock(&objectTableMutex);
if (objectTable == NULL)
{
objectTable = g_hash_table_new ( NULL, NULL );
}
- g_mutex_unlock(objectTableMutex);
+ g_mutex_unlock(&objectTableMutex);
jaw_impl = object_table_lookup( jniEnv, ac );
@@ -284,13 +277,13 @@ jaw_impl_find_instance (JNIEnv *jniEnv, jobject ac)
{
JawImpl *jaw_impl;
- g_mutex_lock(objectTableMutex);
+ g_mutex_lock(&objectTableMutex);
if (objectTable == NULL)
{
- g_mutex_unlock(objectTableMutex);
+ g_mutex_unlock(&objectTableMutex);
return NULL;
}
- g_mutex_unlock(objectTableMutex);
+ g_mutex_unlock(&objectTableMutex);
jaw_impl = object_table_lookup( jniEnv, ac );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]