[frogr] Deserialized pictures only after sets and groups.



commit e787bdc016277e64b4f102bca834394f1b15059a
Author: Mario Sanchez Prada <msanchez gnome org>
Date:   Sun Nov 11 00:54:28 2012 +0100

    Deserialized pictures only after sets and groups.
    
    Pictures will hold references to sets and groups, so those must
    be deserialized and imported into the model first.

 src/frogr-model.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/frogr-model.c b/src/frogr-model.c
index da9548b..ae33b5e 100644
--- a/src/frogr-model.c
+++ b/src/frogr-model.c
@@ -823,13 +823,9 @@ frogr_model_deserialize (FrogrModel *self, JsonNode *json_node)
 
   g_return_if_fail(FROGR_IS_MODEL (self));
 
-  /* First we get the different lists with data */
+  /* First we get the different lists with data for sets, groups and tags */
   root_object = json_node_get_object (json_node);
 
-  array_member = json_object_get_array_member (root_object, "pictures");
-  if (array_member)
-    pictures = _deserialize_list_from_json_array (array_member, FROGR_TYPE_PICTURE);
-
   array_member = json_object_get_array_member (root_object, "photosets");
   if (array_member)
     sets = _deserialize_list_from_json_array (array_member, FROGR_TYPE_PHOTOSET);
@@ -847,6 +843,12 @@ frogr_model_deserialize (FrogrModel *self, JsonNode *json_node)
   frogr_model_set_groups (self, groups);
   frogr_model_set_remote_tags (self, tags);
 
+  /* Pictures must be deserialized at the end, since they will hold
+     references to sets and groups previously imported in the model */
+  array_member = json_object_get_array_member (root_object, "pictures");
+  if (array_member)
+    pictures = _deserialize_list_from_json_array (array_member, FROGR_TYPE_PICTURE);
+
   /* Now we take the list of pictures and carefully ad them into the
      model as long as the associated thumbnails are being loaded */
   loader = frogr_file_loader_new_from_pictures (pictures);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]