Changes to rename_id function:
authorAntony Riakiotakis <kalast@gmail.com>
Sun, 27 Dec 2015 22:22:43 +0000 (23:22 +0100)
committerAntony Riakiotakis <kalast@gmail.com>
Sun, 27 Dec 2015 22:22:43 +0000 (23:22 +0100)
* Don't copy name before entering new_id function. new_id does that for
us already.

* Take a main argument to make the function possible to use with
different databases

* Append BKE_ to rename_id

source/blender/blenkernel/BKE_library.h
source/blender/blenkernel/intern/library.c
source/blender/blenloader/intern/versioning_defaults.c
source/blender/collada/DocumentImporter.cpp

index ff0cad2e5ed406d8a0709f1c9c6a20c7e0f6d1df..336928575afe4027e0c261d7696785aa3fa1dd4d 100644 (file)
@@ -109,7 +109,7 @@ void BKE_main_id_clear_newpoins(struct Main *bmain);
 
 void BKE_main_lib_objects_recalc_all(struct Main *bmain);
 
-void rename_id(struct ID *id, const char *name);
+void BKE_rename_id(struct Main *bmain, struct ID *id, const char *name);
 void name_uiprefix_id(char *name, const struct ID *id);
 void test_idbutton(char *name);
 
index 14e21a8b014a0e9d0673144940847925bef62825..39feb4065eb9aa99b6baa6482a673301b25642cf 100644 (file)
@@ -1831,12 +1831,14 @@ void test_idbutton(char *name)
 /**
  * Sets the name of a block to name, suitably adjusted for uniqueness.
  */
-void rename_id(ID *id, const char *name)
+void BKE_rename_id(Main *bmain, ID *id, const char *name)
 {
        ListBase *lb;
 
-       BLI_strncpy(id->name + 2, name, sizeof(id->name) - 2);
-       lb = which_libbase(G.main, GS(id->name));
+       if (!bmain)
+               bmain = G.main;
+
+       lb = which_libbase(bmain, GS(id->name));
        
        new_id(lb, id, name);
 }
index cf0e443896393e5b27c5d84b5541c2ed981a5a63..1dc3128319f50354e32e5a8c68309a4737426333 100644 (file)
@@ -234,7 +234,7 @@ void BLO_update_defaults_startup_blend(Main *bmain)
                br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Twist");
                if (br)
                {
-                       rename_id(&br->id, "Rotate");
+                       BKE_rename_id(bmain, &br->id, "Rotate");
                }
        }
 }
index 498e65790f3ac1bef1d7a3dd5617fc0f9507cba1..45b8a4fe5d46d1971c0ad73bcbcb334a099a2b01 100644 (file)
@@ -654,7 +654,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
                for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end(); ++it) {
                        ob = *it;
                        std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId();
-                       rename_id(&ob->id, (char *)nodename.c_str());
+                       BKE_rename_id(NULL, &ob->id, (char *)nodename.c_str());
                        object_map.insert(std::pair<COLLADAFW::UniqueId, Object *>(node->getUniqueId(), ob));
                        node_map[node->getUniqueId()] = node;