[java-atk-wrapper] Cope with accessible being destroyed in the meanwhile



commit 449f93b3e345861b006269d5328a9cf84ba5c994
Author: Samuel Thibault <samuel thibault ens-lyon org>
Date:   Thu Jun 20 01:05:25 2019 +0200

    Cope with accessible being destroyed in the meanwhile

 jni/src/AtkWrapper.c   | 3 +++
 jni/src/jawcomponent.c | 3 ++-
 jni/src/jawselection.c | 3 ++-
 3 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/jni/src/AtkWrapper.c b/jni/src/AtkWrapper.c
index e84286a..194f95c 100644
--- a/jni/src/AtkWrapper.c
+++ b/jni/src/AtkWrapper.c
@@ -1192,6 +1192,9 @@ JNICALL Java_org_GNOME_Accessibility_AtkWrapper_getInstance(JNIEnv *jniEnv,
                                                             jclass jClass,
                                                             jobject ac)
 {
+  if (!ac)
+    return NULL;
+
   return jaw_impl_get_instance(jniEnv, ac);
 }
 
diff --git a/jni/src/jawcomponent.c b/jni/src/jawcomponent.c
index 44934de..b75a20e 100644
--- a/jni/src/jawcomponent.c
+++ b/jni/src/jawcomponent.c
@@ -162,7 +162,8 @@ jaw_component_ref_accessible_at_point (AtkComponent *component, gint x, gint y,
 
   JawImpl* jaw_impl = jaw_impl_get_instance_from_jaw( jniEnv, child_ac );
 
-  g_object_ref( G_OBJECT(jaw_impl) );
+  if (jaw_impl)
+    g_object_ref( G_OBJECT(jaw_impl) );
 
   return ATK_OBJECT(jaw_impl);
 }
diff --git a/jni/src/jawselection.c b/jni/src/jawselection.c
index 01247f5..de3e14e 100644
--- a/jni/src/jawselection.c
+++ b/jni/src/jawselection.c
@@ -142,7 +142,8 @@ jaw_selection_ref_selection (AtkSelection *selection, gint i)
        }
 
        AtkObject *obj = (AtkObject*) jaw_impl_get_instance_from_jaw( jniEnv, child_ac );
-       g_object_ref (G_OBJECT(obj));
+       if (obj)
+         g_object_ref (G_OBJECT(obj));
 
        return obj;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]