gboolean
atspi_accessible_is_equal (AtspiAccessible *obj, AtspiAccessible *other)
{
+ static const char prefix[] = "/org/a11y/atspi/accessible/";
+ static const size_t prefix_len = sizeof(prefix)/sizeof(char);
+
if (obj == other)
return TRUE;
if (!obj || !other)
return FALSE;
- return !g_strcmp0(obj->parent.app->bus_name, other->parent.app->bus_name) &&
- !g_strcmp0(obj->parent.path, other->parent.path);
+
+ /*
+ * Is it possible to have 2 different objects representing
+ * the same application? If not we should compare only pointers
+ * (obj->parent.app and other->parent.app)
+ */
+
+ /* One of them is null */
+ if ((obj->parent.app != other->parent.app) && (!obj->parent.app || !other->parent.app))
+ return FALSE;
+
+ /* Both are not null */
+ if ((obj->parent.app != other->parent.app) && g_strcmp0(obj->parent.app->bus_name, other->parent.app->bus_name))
+ return FALSE;
+
+ const AtspiObject *o1 = ATSPI_OBJECT (obj);
+ const AtspiObject *o2 = ATSPI_OBJECT (other);
+
+ const char *path1 = o1 ? o1->path : "";
+ const char *path2 = o2 ? o2->path : "";
+
+ if (!strncmp(path1, prefix, prefix_len))
+ path1 += prefix_len;
+
+ if (!strncmp(path2, prefix, prefix_len))
+ path2 += prefix_len;
+
+ return !g_strcmp0(path1, path2);
}
void