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 629642 - individuals-changed emitted in the wrong order
individuals-changed emitted in the wrong order
Status: RESOLVED FIXED
Product: folks
Classification: Platform
Component: Key file backend
0.1.x
Other Linux
: Normal normal
: gnome-3.0
Assigned To: folks-maint
folks-maint
Depends on:
Blocks:
 
 
Reported: 2010-09-14 11:38 UTC by Marco Barisione
Modified: 2010-09-21 09:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Log produced by folks (14.65 KB, text/plain)
2010-09-14 13:21 UTC, Marco Barisione
  Details
Ensure Individuals are added before they're removed (4.34 KB, patch)
2010-09-15 16:49 UTC, Philip Withnall
committed Details | Review

Description Marco Barisione 2010-09-14 11:38:13 UTC
I have in 4 contacts in Empathy and I merged 3 of them in a single individual called Marco Barisione (yes, I really like to talk to myself).
If a create a folks aggregator, connect to individuals-changed and print what happens I get this (the hex value is the pointer to the individual):
individuals-changed emitted: 
  added: Marco Barisione 0x773910 
individuals-changed emitted:
  removed: Marco Barisione 0x773910 
individuals-changed emitted:
  removed: Marco Barisione 0x773a10 
individuals-changed emitted:
  removed: Marco Barisione 0x773a90 
individuals-changed emitted:
  added: Marco Barisione 0x773b10 
  added: Marco Barisione 0x773a90 
  added: Marco Barisione 0x773a10 
  added: echobot 0x773990 

So my application gets confused (contacts get removed before being added) and shows 3 Marcos and 1 echobot.
Comment 1 Philip Withnall 2010-09-14 12:19:23 UTC
Could you run your program with the FOLKS_DEBUG=all environment variable set please?
Comment 2 Marco Barisione 2010-09-14 13:21:50 UTC
Created attachment 170240 [details]
Log produced by folks
Comment 3 Philip Withnall 2010-09-15 16:49:28 UTC
Created attachment 170354 [details] [review]
Ensure Individuals are added before they're removed

http://git.collabora.co.uk/?p=user/pwith/folks;a=shortlog;h=refs/heads/629642-aggregator-signals

This should fix the problem.

Ultimately, we probably want to reconsider the interplay between the IndividualAggregator.individuals_changed and Individual.removed signals, taking into account the possibility of needing to know a replacement Individual when listening to IndividualAggregator.individuals_changed, the requirement that the API still be usable without IndividualAggregator, and the need to not have two signals to listen to in order to get the same information both times.
Comment 4 Travis Reitter 2010-09-20 17:48:12 UTC
Review of attachment 170354 [details] [review]:

Looks good. Please merge to 0.2.x and master.
Comment 5 Travis Reitter 2010-09-20 17:49:31 UTC
(In reply to comment #3)

> Ultimately, we probably want to reconsider the interplay between the
> IndividualAggregator.individuals_changed and Individual.removed signals, taking
> into account the possibility of needing to know a replacement Individual when
> listening to IndividualAggregator.individuals_changed, the requirement that the
> API still be usable without IndividualAggregator, and the need to not have two
> signals to listen to in order to get the same information both times.

Please add this to bug #629078
Comment 6 Philip Withnall 2010-09-21 09:32:29 UTC
master:

commit 797a0521987d2729de7fa1655f69d06dc7e42d9f
Author: Philip Withnall <philip.withnall@collabora.co.uk>
Date:   Wed Sep 15 17:44:23 2010 +0100

    Ensure Individuals are added before they're removed
    
    Rearrange the linking process slightly so that we can guarantee that
    Individuals won't be signalled as removed (or replaced) before they're
    signalled as added. Closes: bgo#629642

 NEWS                             |    1 +
 folks/individual-aggregator.vala |   45 ++++++++++++++++++++++----------------
 2 files changed, 27 insertions(+), 19 deletions(-)

folks-0-2:

commit dd0386400f74ab8918ee56755deb88f241f4a6f1
Author: Philip Withnall <philip.withnall@collabora.co.uk>
Date:   Wed Sep 15 17:44:23 2010 +0100

    Ensure Individuals are added before they're removed
    
    Rearrange the linking process slightly so that we can guarantee that
    Individuals won't be signalled as removed (or replaced) before they're
    signalled as added. Closes: bgo#629642

 NEWS                             |    6 +++++
 folks/individual-aggregator.vala |   45 ++++++++++++++++++++++----------------
 2 files changed, 32 insertions(+), 19 deletions(-)