[java-atk-wrapper] JNI: Use consistent debug messages
- From: Magdalen Berns <mberns src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [java-atk-wrapper] JNI: Use consistent debug messages
- Date: Sun, 1 Mar 2015 21:25:20 +0000 (UTC)
commit b4f4b5e88030cfeb217f35512f0eeb6bafa7393c
Author: Magdalen Berns <m berns thismagpie com>
Date: Sun Mar 1 21:24:06 2015 +0000
JNI: Use consistent debug messages
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=745386
jni/src/AtkWrapper.c | 26 ++++++++++-----
jni/src/jawimpl.c | 86 +++++++++++++++++++++++--------------------------
2 files changed, 57 insertions(+), 55 deletions(-)
---
diff --git a/jni/src/AtkWrapper.c b/jni/src/AtkWrapper.c
index 440daef..a1ab7f2 100644
--- a/jni/src/AtkWrapper.c
+++ b/jni/src/AtkWrapper.c
@@ -307,6 +307,8 @@ window_open_handler (gpointer p)
}
JawImpl* jaw_impl = jaw_impl_get_instance(jniEnv, global_ac);
+ if (jaw_impl == NULL)
+ g_warning("\n *** window_open_handler: jaw_impl == NULL *** \n");
AtkObject* atk_obj = ATK_OBJECT(jaw_impl);
if (!g_strcmp0(atk_role_get_name(atk_object_get_role(atk_obj)),
@@ -756,7 +758,6 @@ get_int_value (JNIEnv *jniEnv, jobject o)
jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv, classInteger, "intValue", "()I");
return (gint)(*jniEnv)->CallIntMethod(jniEnv, o, jmid);
}
-
static gint64
get_int64_value (JNIEnv *jniEnv, jobject o)
{
@@ -838,6 +839,12 @@ signal_emit_handler (gpointer p)
(*jniEnv)->GetObjectArrayElement(jniEnv, args, 0));
jobject child_ac = (*jniEnv)->GetObjectArrayElement(jniEnv, args, 1);
JawImpl *child_impl = jaw_impl_get_instance(jniEnv, child_ac);
+ if (child_impl == NULL)
+ {
+ g_warning("\n *** signal_emit_handler: child_impl == NULL *** \n");
+ free_callback_para(para);
+ return FALSE;
+ }
if (!child_impl)
{
break;
@@ -871,7 +878,12 @@ signal_emit_handler (gpointer p)
{
jobject child_ac = (*jniEnv)->GetObjectArrayElement(jniEnv, args, 0);
JawImpl *child_impl = jaw_impl_get_instance(jniEnv, child_ac);
-
+ if (child_impl == NULL)
+ {
+ g_warning("\n *** signal_emit_handler: child_impl == NULL *** \n");
+ free_callback_para(para);
+ return FALSE;
+ }
if (!child_impl)
{
break;
@@ -1199,12 +1211,8 @@ component_removed_handler (gpointer p)
}
AtkObject* atk_obj = ATK_OBJECT(jaw_impl);
- if (atk_object_get_role(atk_obj) == ATK_ROLE_TOOL_TIP) {
- atk_object_notify_state_change(atk_obj,
- ATK_STATE_SHOWING,
- 0);
- }
-
+ if (atk_object_get_role(atk_obj) == ATK_ROLE_TOOL_TIP)
+ atk_object_notify_state_change(atk_obj, ATK_STATE_SHOWING, FALSE);
free_callback_para(para);
return FALSE;
@@ -1292,7 +1300,7 @@ key_dispatch_handler (gpointer p)
jfieldID jfidString = (*jniEnv)->GetFieldID(jniEnv, classAtkKeyEvent, "string", "Ljava/lang/String;");
jstring jstr = (jstring)(*jniEnv)->GetObjectField(jniEnv, jAtkKeyEvent, jfidString);
event->length = (gint)(*jniEnv)->GetStringLength(jniEnv, jstr);
- event->string = (gchar*)(*jniEnv)->GetStringUTFChars(jniEnv, jstr, NULL);
+ event->string = (gchar*)(*jniEnv)->GetStringUTFChars(jniEnv, jstr, 0);
// keycode
jfieldID jfidKeycode = (*jniEnv)->GetFieldID(jniEnv, classAtkKeyEvent, "keycode", "I");
diff --git a/jni/src/jawimpl.c b/jni/src/jawimpl.c
index 348043a..9a82dc4 100644
--- a/jni/src/jawimpl.c
+++ b/jni/src/jawimpl.c
@@ -88,7 +88,7 @@ static GHashTable *typeTable = NULL;
static GHashTable *objectTable = NULL;
static void
-object_table_insert (JNIEnv *jniEnv, jobject ac, JawImpl * jaw_impl)
+object_table_insert (JNIEnv *jniEnv, jobject ac, JawImpl* jaw_impl)
{
jclass classAccessibleContext = (*jniEnv)->FindClass( jniEnv,
"javax/accessibility/AccessibleContext");
@@ -97,7 +97,7 @@ object_table_insert (JNIEnv *jniEnv, jobject ac, JawImpl * jaw_impl)
"hashCode",
"()I");
gint hash_key = (gint)(*jniEnv)->CallIntMethod(jniEnv, ac, jmid);
- g_hash_table_insert(objectTable, (gpointer)&hash_key, (gpointer)jaw_impl);
+ g_hash_table_insert(objectTable, (gpointer)&hash_key, (gpointer)&jaw_impl);
}
static JawImpl*
@@ -236,10 +236,10 @@ jaw_impl_get_instance (JNIEnv *jniEnv, jobject ac)
jniEnv = jaw_util_get_jni_env();
if (objectTable == NULL)
{
- objectTable = g_hash_table_new ( NULL, NULL );
+ objectTable = g_hash_table_new (NULL, NULL);
}
- jaw_impl = object_table_lookup( jniEnv, ac );
+ jaw_impl = object_table_lookup(jniEnv, ac);
if (jaw_impl == NULL)
{
@@ -257,25 +257,22 @@ jaw_impl_get_instance (JNIEnv *jniEnv, jobject ac)
jaw_obj->acc_context = global_ac;
jaw_obj->storedData = g_hash_table_new(g_str_hash, g_str_equal);
aggregate_interface(jniEnv, jaw_obj, tflag);
- atk_object_initialize( ATK_OBJECT(jaw_impl), NULL );
- object_table_insert( jniEnv, global_ac, jaw_impl);
+ atk_object_initialize(ATK_OBJECT(jaw_impl), NULL);
+ object_table_insert(jniEnv, global_ac, jaw_impl);
} else {
- printf("\n *** JAW_OBJECT == NULL *** jaw_impl_get_instance: %s \n",
- (char *) (ATK_OBJECT(jaw_obj)));
+ g_warning("\n *** jaw_impl_get_instance: jaw_obj == NULL *** \n");
+ return NULL;
}
- } else {
- printf("\n *** JAW_IMPL == NULL *** jaw_impl_get_instance: %s \n",
- (char *) ATK_OBJECT(jaw_impl));
}
+ } else {
+ g_warning("\n *** jaw_impl_get_instance: global_ac == NULL *** \n");
+ return NULL;
}
}
if (jaw_impl != NULL)
- {
return jaw_impl;
- }
- else {
- printf("\n *** JAW_IMPL == NULL *** jaw_impl_get_instance\n");
- }
+ else
+ g_warning("\n *** jaw_impl_get_instance: jaw_impl == NULL *** \n");
return NULL;
}
@@ -285,14 +282,14 @@ jaw_impl_find_instance (JNIEnv *jniEnv, jobject ac)
JawImpl *jaw_impl;
if (objectTable == NULL)
- return NULL;
-
- jaw_impl = object_table_lookup( jniEnv, ac );
+ {
+ objectTable = g_hash_table_new (NULL, NULL);
+ }
+ jaw_impl = object_table_lookup(jniEnv, ac);
if (jaw_impl == NULL)
{
- printf("\n *** JAW_IMPL == NULL *** jaw_impl_find_instance: %s \n",
- (char *) ATK_OBJECT(jaw_impl));
+ g_warning("\n *** jaw_impl_find_instance: jaw_impl == NULL *** \n");
return NULL;
}
@@ -419,7 +416,7 @@ jaw_impl_get_type (guint tflag)
if (tflag & INTERFACE_EDITABLE_TEXT)
{
- g_type_add_interface_static (type, ATK_TYPE_EDITABLE_TEXT, &atk_editable_text_info);
+ g_type_add_interface_static (type, ATK_TYPE_EDITABLE_TEXT, &atk_editable_text_info);
}
if (tflag & INTERFACE_HYPERTEXT)
@@ -512,10 +509,11 @@ jaw_impl_finalize(GObject *gobject)
g_hash_table_iter_remove(&iter);
}
- g_hash_table_unref(jaw_impl->ifaceTable);
-
- g_hash_table_destroy(jaw_obj->storedData);
-
+ if (jaw_impl->ifaceTable != NULL)
+ {
+ g_hash_table_unref(jaw_impl->ifaceTable);
+ g_hash_table_destroy(jaw_obj->storedData);
+ }
/* Chain up to parent's finalize */
G_OBJECT_CLASS(jaw_impl_parent_class)->finalize(gobject);
}
@@ -525,17 +523,13 @@ jaw_impl_get_interface_data (JawObject *jaw_obj, guint iface)
{
JawImpl *jaw_impl = (JawImpl*)jaw_obj;
- if (jaw_impl == NULL || jaw_impl->ifaceTable == NULL)
- {
+ if (jaw_impl->ifaceTable == NULL)
return NULL;
- }
JawInterfaceInfo *info = g_hash_table_lookup(jaw_impl->ifaceTable, (gpointer)&iface);
- if (info)
- {
+ if (info != NULL)
return info->data;
- }
return NULL;
}
@@ -660,8 +654,7 @@ is_java_relation_key (JNIEnv *jniEnv,jstring jKey, const gchar* strKey)
}
static AtkRelationType
-get_atk_relation_type_from_java_key (JNIEnv *jniEnv,
- jstring jrel_key)
+get_atk_relation_type_from_java_key (JNIEnv *jniEnv, jstring jrel_key)
{
if ( is_java_relation_key(jniEnv, jrel_key, "CHILD_NODE_OF") )
{
@@ -719,11 +712,10 @@ static AtkRelationSet*
jaw_impl_ref_relation_set (AtkObject *atk_obj)
{
if (atk_obj->relation_set)
- {
g_object_unref(G_OBJECT(atk_obj->relation_set));
- }
-
atk_obj->relation_set = atk_relation_set_new();
+ if(atk_obj == NULL)
+ return NULL;
JawObject *jaw_obj = JAW_OBJECT(atk_obj);
jobject ac = jaw_obj->acc_context;
@@ -738,7 +730,7 @@ jaw_impl_ref_relation_set (AtkObject *atk_obj)
jobject jrel_set = (*jniEnv)->CallObjectMethod( jniEnv, ac, jmid );
jclass classAccessibleRelationSet = (*jniEnv)->FindClass( jniEnv,
- "javax/accessibility/AccessibleRelationSet" );
+ "javax/accessibility/AccessibleRelationSet");
jmid = (*jniEnv)->GetMethodID(jniEnv,
classAccessibleRelationSet,
"toArray",
@@ -751,20 +743,19 @@ jaw_impl_ref_relation_set (AtkObject *atk_obj)
{
jobject jrel = (*jniEnv)->GetObjectArrayElement(jniEnv, jrel_arr, i);
jclass classAccessibleRelation = (*jniEnv)->FindClass( jniEnv,
- "javax/accessibility/AccessibleRelation" );
+ "javax/accessibility/AccessibleRelation");
jmid = (*jniEnv)->GetMethodID(jniEnv,
classAccessibleRelation,
"getKey",
- "()Ljava/lang/String;" );
+ "()Ljava/lang/String;");
jstring jrel_key = (*jniEnv)->CallObjectMethod( jniEnv, jrel, jmid );
-
AtkRelationType rel_type = get_atk_relation_type_from_java_key(jniEnv, jrel_key);
jmid = (*jniEnv)->GetMethodID(jniEnv,
classAccessibleRelation,
"getTarget",
"()[Ljava/lang/Object;");
- jobjectArray jtarget_arr = (*jniEnv)->CallObjectMethod( jniEnv, jrel, jmid );
+ jobjectArray jtarget_arr = (*jniEnv)->CallObjectMethod(jniEnv, jrel, jmid);
jsize jtarget_size = (*jniEnv)->GetArrayLength(jniEnv, jtarget_arr);
jsize j;
@@ -772,21 +763,24 @@ jaw_impl_ref_relation_set (AtkObject *atk_obj)
{
jobject jtarget = (*jniEnv)->GetObjectArrayElement(jniEnv, jtarget_arr, j);
jclass classAccessible = (*jniEnv)->FindClass( jniEnv,
- "javax/accessibility/Accessible" );
+ "javax/accessibility/Accessible");
if ((*jniEnv)->IsInstanceOf(jniEnv, jtarget, classAccessible))
{
jmid = (*jniEnv)->GetMethodID(jniEnv,
classAccessible,
"getAccessibleContext",
"()Ljavax/accessibility/AccessibleContext;");
- jobject target_ac = (*jniEnv)->CallObjectMethod( jniEnv, jtarget, jmid );
+ jobject target_ac = (*jniEnv)->CallObjectMethod(jniEnv, jtarget, jmid);
- JawImpl *target_obj = jaw_impl_get_instance( jniEnv, target_ac );
+ JawImpl *target_obj = jaw_impl_get_instance(jniEnv, target_ac);
+ if(target_obj == NULL)
+ return NULL;
atk_object_add_relationship(atk_obj, rel_type, (AtkObject*) target_obj);
}
}
}
-
+ if(atk_obj->relation_set == NULL)
+ return NULL;
g_object_ref (atk_obj->relation_set);
return atk_obj->relation_set;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]