[gnome-contacts] Don't unnecessarily create a main persona
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Don't unnecessarily create a main persona
- Date: Fri, 9 Sep 2011 12:18:47 +0000 (UTC)
commit e782402d5c9aa6b6234a764fd23c6394841ca1b7
Author: Alexander Larsson <alexl redhat com>
Date: Thu Sep 8 21:37:07 2011 +0200
Don't unnecessarily create a main persona
If for instance there is only only one persona left, there is no need
to relink it
src/contacts-linking.vala | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/contacts-linking.vala b/src/contacts-linking.vala
index 95663c0..697ed4d 100644
--- a/src/contacts-linking.vala
+++ b/src/contacts-linking.vala
@@ -715,7 +715,9 @@ namespace Contacts {
other_personas.add (p3);
}
- if (main_persona == null) {
+ // If we didn't find a main persona, and we need one because there are
+ // other personas that we need to ensure linking in, then create one
+ if (main_persona == null && other_personas.size > 1) {
var details = new HashTable<string, Value?> (str_hash, str_equal);
try {
main_persona = yield contact.store.aggregator.primary_store.add_persona_from_details (details);
@@ -729,9 +731,8 @@ namespace Contacts {
// First apply all additions on the primary persona so that we avoid temporarily being
// unlinked and then relinked
- // Note, this may cause a new persona to be added to the individual if
- // main_persona is null
- yield persona_apply_attributes (main_persona, main_persona_additions, other_personas_removals);
+ if (main_persona != null)
+ yield persona_apply_attributes (main_persona, main_persona_additions, other_personas_removals);
foreach (var p in other_personas) {
yield persona_apply_attributes (p, null, other_personas_removals);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]