Merging r58475 through r58700 from trunk into soc-2013-depsgraph_mt
[blender.git] / source / blender / blenloader / intern / readfile.c
index d78edc80654a9a241880bc99d4031d00db50a0f6..e71b3c644599f66c1f4a7e0f736b7e4f9162c713 100644 (file)
@@ -3115,7 +3115,6 @@ static void direct_link_mball(FileData *fd, MetaBall *mb)
        
        mb->disp.first = mb->disp.last = NULL;
        mb->editelems = NULL;
-       mb->bb = NULL;
 /*     mb->edit_elems.first= mb->edit_elems.last= NULL;*/
        mb->lastelem = NULL;
 }
@@ -4818,8 +4817,6 @@ static void direct_link_object(FileData *fd, Object *ob)
                ob->mode &= ~(OB_MODE_EDIT | OB_MODE_PARTICLE_EDIT);
        }
        
-       ob->disp.first = ob->disp.last = NULL;
-       
        ob->adt = newdataadr(fd, ob->adt);
        direct_link_animdata(fd, ob->adt);
        
@@ -5015,8 +5012,7 @@ static void direct_link_object(FileData *fd, Object *ob)
        link_list(fd, &ob->pc_ids);
 
        /* Runtime curve data  */
-       ob->bev.first = ob->bev.last = NULL;
-       ob->path = NULL;
+       ob->curve_cache = NULL;
 
        /* in case this value changes in future, clamp else we get undefined behavior */
        CLAMP(ob->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
@@ -5710,8 +5706,9 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                ntree = nodetree_from_id(snode->id);
                                                if (ntree)
                                                        snode->nodetree = ntree;
-                                               else
-                                                       snode->nodetree = newlibadr(fd, sc->id.lib, snode->nodetree);
+                                               else {
+                                                       snode->nodetree = newlibadr_us(fd, sc->id.lib, snode->nodetree);
+                                               }
                                                
                                                for (path = snode->treepath.first; path; path = path->next) {
                                                        if (path == snode->treepath.first) {
@@ -5719,7 +5716,7 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                                path->nodetree = snode->nodetree;
                                                        }
                                                        else
-                                                               path->nodetree = newlibadr(fd, sc->id.lib, path->nodetree);
+                                                               path->nodetree = newlibadr_us(fd, sc->id.lib, path->nodetree);
                                                        
                                                        if (!path->nodetree)
                                                                break;
@@ -5804,21 +5801,23 @@ static void *restore_pointer_by_name(Main *mainp, ID *id, int user)
        return NULL;
 }
 
+static void lib_link_seq_clipboard_pt_restore(ID *id, Main *newmain)
+{
+       if (id) {
+               /* clipboard must ensure this */
+               BLI_assert(id->newid != NULL);
+               id->newid = restore_pointer_by_name(newmain, (ID *)id->newid, 1);
+       }
+}
 static int lib_link_seq_clipboard_cb(Sequence *seq, void *arg_pt)
 {
        Main *newmain = (Main *)arg_pt;
-       
-       if (seq->sound) {
-               seq->sound = restore_pointer_by_name(newmain, (ID *)seq->sound, 0);
-               seq->sound->id.us++;
-       }
-       
-       if (seq->scene)
-               seq->scene = restore_pointer_by_name(newmain, (ID *)seq->scene, 1);
-       
-       if (seq->scene_camera)
-               seq->scene_camera = restore_pointer_by_name(newmain, (ID *)seq->scene_camera, 1);
-       
+
+       lib_link_seq_clipboard_pt_restore((ID *)seq->scene, newmain);
+       lib_link_seq_clipboard_pt_restore((ID *)seq->scene_camera, newmain);
+       lib_link_seq_clipboard_pt_restore((ID *)seq->clip, newmain);
+       lib_link_seq_clipboard_pt_restore((ID *)seq->mask, newmain);
+       lib_link_seq_clipboard_pt_restore((ID *)seq->sound, newmain);
        return 1;
 }
 
@@ -6048,7 +6047,7 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc
                                                        path->nodetree = snode->nodetree;
                                                }
                                                else
-                                                       path->nodetree= restore_pointer_by_name(newmain, (ID*)path->nodetree, 0);
+                                                       path->nodetree= restore_pointer_by_name(newmain, (ID*)path->nodetree, 2);
                                                
                                                if (!path->nodetree)
                                                        break;
@@ -7690,31 +7689,38 @@ static const char *node_get_static_idname(int type, int treetype)
 static const char *node_socket_get_static_idname(bNodeSocket *sock)
 {
        switch (sock->type) {
-       case SOCK_FLOAT: {
-               bNodeSocketValueFloat *dval = sock->default_value;
-               return nodeStaticSocketType(SOCK_FLOAT, dval->subtype);
-       }
-       case SOCK_INT: {
-               bNodeSocketValueInt *dval = sock->default_value;
-               return nodeStaticSocketType(SOCK_INT, dval->subtype);
-       }
-       case SOCK_BOOLEAN: {
-               return nodeStaticSocketType(SOCK_BOOLEAN, PROP_NONE);
-       }
-       case SOCK_VECTOR: {
-               bNodeSocketValueVector *dval = sock->default_value;
-               return nodeStaticSocketType(SOCK_VECTOR, dval->subtype);
-       }
-       case SOCK_RGBA: {
-               return nodeStaticSocketType(SOCK_RGBA, PROP_NONE);
-       }
-       case SOCK_STRING: {
-               bNodeSocketValueString *dval = sock->default_value;
-               return nodeStaticSocketType(SOCK_STRING, dval->subtype);
-       }
-       case SOCK_SHADER: {
-               return nodeStaticSocketType(SOCK_SHADER, PROP_NONE);
-       }
+               case SOCK_FLOAT:
+               {
+                       bNodeSocketValueFloat *dval = sock->default_value;
+                       return nodeStaticSocketType(SOCK_FLOAT, dval->subtype);
+               }
+               case SOCK_INT:
+               {
+                       bNodeSocketValueInt *dval = sock->default_value;
+                       return nodeStaticSocketType(SOCK_INT, dval->subtype);
+               }
+               case SOCK_BOOLEAN:
+               {
+                       return nodeStaticSocketType(SOCK_BOOLEAN, PROP_NONE);
+               }
+               case SOCK_VECTOR:
+               {
+                       bNodeSocketValueVector *dval = sock->default_value;
+                       return nodeStaticSocketType(SOCK_VECTOR, dval->subtype);
+               }
+               case SOCK_RGBA:
+               {
+                       return nodeStaticSocketType(SOCK_RGBA, PROP_NONE);
+               }
+               case SOCK_STRING:
+               {
+                       bNodeSocketValueString *dval = sock->default_value;
+                       return nodeStaticSocketType(SOCK_STRING, dval->subtype);
+               }
+               case SOCK_SHADER:
+               {
+                       return nodeStaticSocketType(SOCK_SHADER, PROP_NONE);
+               }
        }
        return "";
 }
@@ -9481,7 +9487,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
 
-
+       if (!MAIN_VERSION_ATLEAST(main, 268, 1)) {
+               Brush *brush;
+               for (brush = main->brush.first; brush; brush = brush->id.next) {
+                       brush->spacing = MAX2(1, brush->spacing);
+               }
+       }
+       
        {
                bScreen *sc;
                Object *ob;