[folks] core: Fix FOLKS_DISABLE_LINKING
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] core: Fix FOLKS_DISABLE_LINKING
- Date: Sat, 5 Apr 2014 17:35:50 +0000 (UTC)
commit 1b770fb19a9c1b8e5f9ce0e3ab00d75fd3af5ca1
Author: Renato Araujo Oliveira Filho <renato filho canonical com>
Date: Mon Mar 31 16:14:16 2014 -0300
core: Fix FOLKS_DISABLE_LINKING
The second step of the _add_personas() function looks at candidate_inds,
which is currently populated even if linking is disabled (in a failed
attempt to keep all the FOLKS_DISABLE_LINKING logic to a single
if-statement at the bottom of the function).
This patch takes a different approach, and ensures that candidate_inds
is not populated if FOLKS_DISABLE_LINKING is enabled, adding an
assertion to try and prevent this bug being re-introduced in future.
A test case will be added in a future commit (see the bug report).
https://bugzilla.gnome.org/show_bug.cgi?id=727405
NEWS | 3 ++-
folks/individual-aggregator.vala | 18 ++++++++++++++----
2 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/NEWS b/NEWS
index 60fbc54..6380bd6 100644
--- a/NEWS
+++ b/NEWS
@@ -11,13 +11,14 @@ Bugs fixed:
• Bug 648811 — Add a dummy backend
• Bug 720707 — New strings partly not translatable
• Bug 722335 — non-void function should return a value
- • Bug 723054 - edsf-persona.vala:1666.21-1666.79: error: Reference transfer
+ • Bug 723054 — edsf-persona.vala:1666.21-1666.79: error: Reference transfer
not supported for this expression
• Bug 723540 — standalone-individuals test failing with master
• Bug 724339 — vala.m4: don't keep generated files in git
• Bug 724809 — Fail to unset contact favorite
• Bug 722892 — Linking personas on Dummy backend does not work
• Bug 726980 — dependency on e-d-s 3.9 is often unnecessary
+ • Bug 727405 — setting FOLKS_DISABLE_LINKING to on does not work
API changes:
• Add Individual.display_name
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 06d0f3d..e1da1da 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -1213,7 +1213,8 @@ public class Folks.IndividualAggregator : Object
/* If the Persona is the user, we *always* want to link it to the
* existing this.user. */
- if (persona.is_user == true && user != null &&
+ if (this._linking_enabled == true &&
+ persona.is_user == true && user != null &&
((!) user).has_anti_link_with_persona (persona) == false)
{
debug (" Found candidate individual '%s' as user.",
@@ -1223,7 +1224,8 @@ public class Folks.IndividualAggregator : Object
/* If we don't trust the PersonaStore at all, we can't link the
* Persona to any existing Individual */
- if (trust_level != PersonaStoreTrust.NONE)
+ if (this._linking_enabled == true &&
+ trust_level != PersonaStoreTrust.NONE)
{
unowned GenericArray<Individual>? candidates =
this._link_map.get (persona.iid);
@@ -1245,7 +1247,8 @@ public class Folks.IndividualAggregator : Object
}
}
- if (persona.store.trust_level == PersonaStoreTrust.FULL)
+ if (this._linking_enabled == true &&
+ persona.store.trust_level == PersonaStoreTrust.FULL)
{
/* If we trust the PersonaStore the Persona came from, we can
* attempt to link based on its linkable properties. */
@@ -1304,6 +1307,7 @@ public class Folks.IndividualAggregator : Object
/* Ensure the original persona makes it into the final individual */
final_personas.add (persona);
+ assert (this._linking_enabled == true || candidate_inds.size == 0);
if (candidate_inds.size > 0 && this._linking_enabled == true)
{
/* The Persona's IID or linkable properties match one or more
@@ -1316,7 +1320,7 @@ public class Folks.IndividualAggregator : Object
final_personas.add_all (individual.personas);
}
}
- else if (candidate_inds.size > 0)
+ else if (!this._linking_enabled)
{
debug (" Linking disabled.");
}
@@ -1400,6 +1404,12 @@ public class Folks.IndividualAggregator : Object
private void _persona_linkable_property_changed_cb (Object obj,
ParamSpec pspec)
{
+ /* Ignore it if the link is disabled */
+ if (this._linking_enabled == false)
+ {
+ return;
+ }
+
/* The value of one of the linkable properties of one the personas has
* changed, so that persona might require re-linking. We do this in a
* simplistic and hacky way (which should work) by simply treating the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]