diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2017-03-01 21:56:37 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2017-03-01 22:13:40 +0300 |
commit | 0f7a664731eb6e22d9c838f33fb62b2a16182538 (patch) | |
tree | decefc848233fecb4c2d0050f0a9e60ad9891a4e /source | |
parent | 18684e546f25feefa5a696b786e74fd63b590d10 (diff) |
Fix collection renaming not checking for unique name in entire hierarchy
Only checked for unique name in direct children of the master
collection.
Also added missing listener for outliner.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 31 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/space_outliner.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 10 |
3 files changed, 32 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index b9a554f181f..370a5953964 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -24,6 +24,8 @@ * \ingroup bke */ +#include <string.h> + #include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_iterator.h" @@ -179,13 +181,38 @@ SceneCollection *BKE_collection_master(const Scene *scene) return scene->collection; } +struct UniqueNameCheckData { + ListBase *lb; + SceneCollection *lookup_sc; +}; + +static bool collection_unique_name_check(void *arg, const char *name) +{ + struct UniqueNameCheckData *data = arg; + + for (SceneCollection *sc = data->lb->first; sc; sc = sc->next) { + struct UniqueNameCheckData child_data = {.lb = &sc->scene_collections, .lookup_sc = data->lookup_sc}; + + if (sc != data->lookup_sc) { + if (STREQ(sc->name, name)) { + return true; + } + } + if (collection_unique_name_check(&child_data, name)) { + return true; + } + } + + return false; +} + void BKE_collection_rename(const Scene *scene, SceneCollection *sc, const char *name) { SceneCollection *sc_master = BKE_collection_master(scene); + struct UniqueNameCheckData data = {.lb = &sc_master->scene_collections, .lookup_sc = sc}; BLI_strncpy(sc->name, name, sizeof(sc->name)); - BLI_uniquename(&sc_master->scene_collections, sc, DATA_("Collection"), '.', offsetof(SceneCollection, name), - sizeof(sc->name)); + BLI_uniquename_cb(collection_unique_name_check, &data, DATA_("Collection"), '.', sc->name, sizeof(sc->name)); } /** diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 348a4488f57..0014b1f048e 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -316,6 +316,7 @@ static void outliner_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(s case ND_RENDER_OPTIONS: case ND_SEQUENCER: case ND_LAYER: + case ND_LAYER_CONTENT: case ND_WORLD: ED_region_tag_redraw(ar); break; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 86140eaaa05..cefc4a59da7 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2262,10 +2262,7 @@ static void rna_SceneCollection_name_set(PointerRNA *ptr, const char *value) { Scene *scene = (Scene *)ptr->id.data; SceneCollection *sc = (SceneCollection *)ptr->data; - SceneCollection *sc_master = BKE_collection_master(scene); - - BLI_strncpy_utf8(sc->name, value, sizeof(sc->name)); - BLI_uniquename(&sc_master->scene_collections, sc, DATA_("SceneCollection"), '.', offsetof(SceneCollection, name), sizeof(sc->name)); + BKE_collection_rename(scene, sc, value); } static void rna_SceneCollection_filter_set(PointerRNA *ptr, const char *value) @@ -2517,10 +2514,7 @@ static void rna_LayerCollection_name_set(PointerRNA *ptr, const char *value) { Scene *scene = (Scene *)ptr->id.data; SceneCollection *sc = ((LayerCollection *)ptr->data)->scene_collection; - SceneCollection *sc_master = BKE_collection_master(scene); - - BLI_strncpy_utf8(sc->name, value, sizeof(sc->name)); - BLI_uniquename(&sc_master->scene_collections, sc, DATA_("SceneCollection"), '.', offsetof(SceneCollection, name), sizeof(sc->name)); + BKE_collection_rename(scene, sc, value); } static PointerRNA rna_LayerCollection_objects_get(CollectionPropertyIterator *iter) |