[folks] Ensure existing Kf.Personas aren't overwritten when choosing new group names
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Ensure existing Kf.Personas aren't overwritten when choosing new group names
- Date: Mon, 30 Aug 2010 19:31:03 +0000 (UTC)
commit 65d2b501696253f82afc14f018e1a3fce737a68e
Author: Philip Withnall <philip withnall collabora co uk>
Date: Mon Aug 30 17:38:09 2010 +0100
Ensure existing Kf.Personas aren't overwritten when choosing new group names
If a key file contained several groups which weren't contiguously numbered on
startup, IDs for new groups would start from the first unused ID, and continue
happily into the next block of IDs which were already in use. This patch
ensures that if an ID is already in use, it won't be again for a new
Kf.Persona. Closes: bgo#628294
backends/key-file/kf-persona-store.vala | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/backends/key-file/kf-persona-store.vala b/backends/key-file/kf-persona-store.vala
index 23c0fb4..48e411d 100644
--- a/backends/key-file/kf-persona-store.vala
+++ b/backends/key-file/kf-persona-store.vala
@@ -199,8 +199,15 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
debug ("Adding Persona from details.");
- string persona_id = this.first_unused_id.to_string ();
- this.first_unused_id++;
+ /* Find the first unused ID, taking into account that the IDs in the key
+ * file may not be contiguous. */
+ string persona_id = null;
+ do
+ {
+ persona_id = this.first_unused_id.to_string ();
+ this.first_unused_id++;
+ }
+ while (this.key_file.has_group (persona_id) == true);
/* Create a new persona and set its im-addresses property to update the
* key file */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]