After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 724809 - Fail to unset contact favorite
Fail to unset contact favorite
Status: RESOLVED FIXED
Product: folks
Classification: Platform
Component: e-d-s backend
git master
Other Linux
: Normal critical
: Unset
Assigned To: folks-maint
folks-maint
Depends on:
Blocks:
 
 
Reported: 2014-02-20 16:42 UTC by Renato Araujo Oliveira Filho
Modified: 2014-02-21 00:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix the bug calling the external function (983 bytes, patch)
2014-02-20 16:53 UTC, Renato Araujo Oliveira Filho
rejected Details | Review
Fix the bug using remove_attributes which uses the attribute name (685 bytes, patch)
2014-02-20 16:58 UTC, Renato Araujo Oliveira Filho
reviewed Details | Review
replace all call of remove_attribute (1.44 KB, patch)
2014-02-21 00:04 UTC, Renato Araujo Oliveira Filho
committed Details | Review

Description Renato Araujo Oliveira Filho 2014-02-20 16:42:39 UTC
Calling the function:

folks_favourite_details_change_is_favourite(details, FALSE, ...)

does not remove the persona favorite attribute.
Comment 1 Renato Araujo Oliveira Filho 2014-02-20 16:46:02 UTC
After some investigation I found where the problem is. The function:

private void _remove_attribute (E.Contact contact, string attr_name)
    {
      unowned VCardAttribute? attr = contact.get_attribute (attr_name) ;
      if (attr != null)
        {
          contact.remove_attribute ((!)attr);
          //e_vcard_remove_attribute(contact, attr);
        }
    }

is generating a wrong c code:

static void _edsf_persona_store_remove_attribute (EdsfPersonaStore* self, EContact* contact, const gchar* attr_name) {
	EVCardAttribute* attr = NULL;
	EContact* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	EVCardAttribute* _tmp2_ = NULL;
	EVCardAttribute* _tmp3_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (contact != NULL);
	g_return_if_fail (attr_name != NULL);
	_tmp0_ = contact;
	_tmp1_ = attr_name;
	_tmp2_ = e_vcard_get_attribute ((EVCard*) _tmp0_, _tmp1_);
	attr = _tmp2_;
	_tmp3_ = attr;
	if (_tmp3_ != NULL) {
		EContact* _tmp4_ = NULL;
		EVCardAttribute* _tmp5_ = NULL;
		EVCardAttribute* _tmp6_ = NULL;
		_tmp4_ = contact;
		_tmp5_ = attr;
		_tmp6_ = __vala_EVCardAttribute_copy0 ((EVCardAttribute*) _tmp5_);
		e_vcard_remove_attribute ((EVCard*) _tmp4_, _tmp6_);
	}
}


Note that the genereted code is creating a copy of the attribute before call the function "e_vcard_remove_attribute" which is wrong.
Comment 2 Renato Araujo Oliveira Filho 2014-02-20 16:53:46 UTC
Created attachment 269817 [details] [review]
Fix the bug calling the external function
Comment 3 Renato Araujo Oliveira Filho 2014-02-20 16:58:10 UTC
Created attachment 269819 [details] [review]
Fix the bug using remove_attributes which uses the attribute name
Comment 4 Travis Reitter 2014-02-20 23:52:11 UTC
This problem comes down to:

1. the EVCardAttribute* passed in to e_vcard_remove_attribute() needs to be the original pointer, not a pointer to a copy of the original
2. Vala works on a copy because that argument is transfer=full and it doesn't want to lose access to it once the call to e_vcard_remove_attribute() is done.

I think this is mostly eds's fault because freeing an argument is convenient in C (if you know exactly that that's going to happen) but obviously gives the caller less control.

We can't change the EDS API for this and I don't know if this is fixable in a clean way in Vala, so I think the best option is to fix this in Folks itself.
Comment 5 Travis Reitter 2014-02-20 23:54:08 UTC
Review of attachment 269819 [details] [review]:

Please replace the other instance in this file of EVCard.remove_attribute(attr) with EVCard.remove_attributes(null, attr_name) and push to master.
Comment 6 Travis Reitter 2014-02-20 23:54:53 UTC
Review of attachment 269817 [details] [review]:

I'd much prefer to not do it this way as it's unconventional and better handled by the other patch.
Comment 7 Renato Araujo Oliveira Filho 2014-02-21 00:04:42 UTC
Created attachment 269851 [details] [review]
replace all call of remove_attribute
Comment 8 Renato Araujo Oliveira Filho 2014-02-21 00:05:20 UTC
(In reply to comment #5)
> Review of attachment 269819 [details] [review]:
> 
> Please replace the other instance in this file of EVCard.remove_attribute(attr)
> with EVCard.remove_attributes(null, attr_name) and push to master.

I have pushed a new patch, I do not think I have permission to push to master.
Comment 9 Travis Reitter 2014-02-21 00:26:49 UTC
Review of attachment 269851 [details] [review]:

I made some minor changes (including using the attribute name instead of the attribute itself for the second function call) and pushed to master. Thanks again!


commit 87e037787476ba645ced4b8d6a406b32f7dbfae0
Author: Renato Araujo Oliveira Filho <renato.filho@canonical.com>
Date:   Thu Feb 20 18:21:27 2014 -0300

    Replaced use of EVCard.remove_attribute to EVCard.remove_attributes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724809

 NEWS                                     |  1 +
 backends/eds/lib/edsf-persona-store.vala | 14 +++++---------
 2 files changed, 6 insertions(+), 9 deletions(-)