GNOME Bugzilla – Bug 578602
atk_object_add_relationship doesn't add relationship which already exists, but returns TRUE
Last modified: 2012-03-26 18:24:39 UTC
From description of function gboolean atk_object_add_relationship(AtkObject *object, AtkRelationType relationship, AtkObject *target): Adds a relationship of the specified type with the specified target. ... Returns : TRUE if the relationship is added. After patch at 2008-11-10, which fix bug 477708, the function doesn't add relationship, if it already exists in object's relation set. But it returns TRUE anyway, that's wrong.
Created attachment 132581 [details] reproduce bug On atk-1.25 and later test output is: Number of relationships after first call: 1. Second call of atk_object_add_relationship returns TRUE. Number of relationships after second call: 1.
Created attachment 177335 [details] [review] Fixes the bug The straightforward solution for this bug is just return FALSE is the relation is already present on the object relation set.
Review of attachment 177335 [details] [review]: Patch looks good.
(In reply to comment #3) > Review of attachment 177335 [details] [review]: > > Patch looks good. Ok, I will apply it during the day.
Patch applied, so bug fixed. But I can't close this bug as FIXED. Li or Andrey, could you close the bug? Thanks
With the commit of the fix, I'm seeing a different set of failures out of lsb-test-desktop-t2c (which I believe the original reported developed). It would appear than now trying to add a different target with a type already used to a relation set also fails. Is this the desired behavior?
(In reply to comment #6) > With the commit of the fix, I'm seeing a different set of failures out of > lsb-test-desktop-t2c (which I believe the original reported developed). It > would appear than now trying to add a different target with a type already used > to a relation set also fails. Is this the desired behavior? After a look to the code I think that you are right. Before my patch (see comment 2), if the target was not included on the relationship, it gets the relation and adds the target. So in order to check if the relationship was added or not, you need to check the relationship and the target. Something that current relationset API doesn't have. So a new method is required: /** * atk_relation_set_contains_extra: * @set: an #AtkRelationSet * @relationship: an #AtkRelationType * @target: an #AtkObject * * Determines whether the relation set contains a relation that matches the * specified type and target * * Returns: %TRUE if @relationship is the relationship type of a relation * in @set with @target as one of his targets, %FALSE otherwise And replace atk_relation_set_contains with atk_relation_set_contains_extra (this name is temporal, a real one is required). Anyway, today is GNOME 3.4 release day, so I can include it. I will work on that for the next release 3.6 Meanwhile, I will create a bug to handle the bug introduced and the new API required.
(In reply to comment #7) > Meanwhile, I will create a bug to handle the bug introduced and the new API > required. Done, bug 672869.