diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2017-03-01 18:32:13 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2017-03-01 18:34:16 +0300 |
commit | 18684e546f25feefa5a696b786e74fd63b590d10 (patch) | |
tree | 26ca4b6896783bfe2b822f2e4b2a3009df824f45 /source/blender/blenkernel | |
parent | b00b9dadd819d3b94405f755131e609afa827438 (diff) |
Outliner: Make sure collection name is unique after renaming
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_collection.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 13 |
2 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h index 644bcef6226..45014b801b5 100644 --- a/source/blender/blenkernel/BKE_collection.h +++ b/source/blender/blenkernel/BKE_collection.h @@ -45,6 +45,7 @@ struct Scene; struct SceneCollection *BKE_collection_add(struct Scene *scene, struct SceneCollection *sc_parent, const char *name); bool BKE_collection_remove(struct Scene *scene, struct SceneCollection *sc); struct SceneCollection *BKE_collection_master(const struct Scene *scene); +void BKE_collection_rename(const struct Scene *scene, struct SceneCollection *sc, const char *name); void BKE_collection_master_free(struct Scene *scene); void BKE_collection_object_add(struct Scene *scene, struct SceneCollection *sc, struct Object *object); void BKE_collection_object_add_from(struct Scene *scene, struct Object *ob_src, struct Object *ob_dst); diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 18af75771c0..b9a554f181f 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -62,9 +62,7 @@ SceneCollection *BKE_collection_add(Scene *scene, SceneCollection *sc_parent, co sc_parent = sc_master; } - BLI_strncpy(sc->name, name, sizeof(sc->name)); - BLI_uniquename(&sc_master->scene_collections, sc, DATA_("Collection"), '.', offsetof(SceneCollection, name), sizeof(sc->name)); - + BKE_collection_rename(scene, sc, name); BLI_addtail(&sc_parent->scene_collections, sc); BKE_layer_sync_new_scene_collection(scene, sc_parent, sc); @@ -181,6 +179,15 @@ SceneCollection *BKE_collection_master(const Scene *scene) return scene->collection; } +void BKE_collection_rename(const Scene *scene, SceneCollection *sc, const char *name) +{ + SceneCollection *sc_master = BKE_collection_master(scene); + + BLI_strncpy(sc->name, name, sizeof(sc->name)); + BLI_uniquename(&sc_master->scene_collections, sc, DATA_("Collection"), '.', offsetof(SceneCollection, name), + sizeof(sc->name)); +} + /** * Free (or release) any data used by the master collection (does not free the master collection itself). * Used only to clear the entire scene data since it's not doing re-syncing of the LayerCollection tree |