Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-05-23 14:39:35 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-05-23 14:52:51 +0300
commit7c5e174871e83dfe874da491613a65fbf405099e (patch)
tree4551032a1fd0dfefacf6bb01e429c8f607fb5c54 /source/blender/blenkernel
parent37b947c7ef69e62fa13b795d2b9de0e030cdfd7c (diff)
Fix T55160: crash renaming view layer.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_animsys.h19
-rw-r--r--source/blender/blenkernel/BKE_layer.h2
-rw-r--r--source/blender/blenkernel/intern/layer.c29
3 files changed, 40 insertions, 10 deletions
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index 71c63df7bf3..8b71d97c0e5 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -31,23 +31,22 @@
* \author Joshua Leung
*/
-struct ID;
-struct ListBase;
-struct Main;
struct AnimData;
+struct AnimMapper;
struct FCurve;
-struct KeyingSet;
+struct ID;
struct KS_Path;
+struct KeyingSet;
+struct ListBase;
+struct Main;
struct PathResolvedRNA;
-struct bContext;
-
struct PointerRNA;
struct PropertyRNA;
struct ReportList;
+struct Scene;
struct bAction;
struct bActionGroup;
-struct AnimMapper;
-struct FCurve;
+struct bContext;
/* ************************************* */
/* AnimData API */
@@ -119,7 +118,7 @@ void BKE_keyingsets_free(struct ListBase *list);
/* Path Fixing API */
/* Get a "fixed" version of the given path (oldPath) */
-char *BKE_animsys_fix_rna_path_rename(ID *owner_id, char *old_path, const char *prefix, const char *oldName,
+char *BKE_animsys_fix_rna_path_rename(struct ID *owner_id, char *old_path, const char *prefix, const char *oldName,
const char *newName, int oldSubscript, int newSubscript, bool verify_paths);
/* Fix all the paths for the given ID + Action */
@@ -132,7 +131,7 @@ void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, st
bool verify_paths);
/* Fix all the paths for the entire database... */
-void BKE_animdata_fix_paths_rename_all(ID *ref_id, const char *prefix, const char *oldName, const char *newName);
+void BKE_animdata_fix_paths_rename_all(struct ID *ref_id, const char *prefix, const char *oldName, const char *newName);
/* Fix the path after removing elements that are not ID (e.g., node) */
void BKE_animdata_fix_paths_remove(struct ID *id, const char *path);
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 9daf33baf10..626a1cd09e3 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -80,6 +80,8 @@ void BKE_view_layer_copy_data(
struct ViewLayer *view_layer_dst, const struct ViewLayer *view_layer_src,
const int flag);
+void BKE_view_layer_rename(struct Scene *scene, struct ViewLayer *view_layer, const char *name);
+
struct LayerCollection *BKE_layer_collection_get_active(struct ViewLayer *view_layer);
bool BKE_layer_collection_activate(struct ViewLayer *view_layer, struct LayerCollection *lc);
struct LayerCollection *BKE_layer_collection_activate_parent(struct ViewLayer *view_layer, struct LayerCollection *lc);
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 6d875ecb516..648d5f02d4d 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -34,6 +34,7 @@
#include "BLI_threads.h"
#include "BLT_translation.h"
+#include "BKE_animsys.h"
#include "BKE_collection.h"
#include "BKE_freestyle.h"
#include "BKE_global.h"
@@ -387,6 +388,34 @@ void BKE_view_layer_copy_data(
// TODO: not always safe to free BKE_layer_collection_sync(scene_dst, view_layer_dst);
}
+void BKE_view_layer_rename(Scene *scene, ViewLayer *view_layer, const char *newname)
+{
+ char oldname[sizeof(view_layer->name)];
+
+ BLI_strncpy(oldname, view_layer->name, sizeof(view_layer->name));
+
+ BLI_strncpy_utf8(view_layer->name, newname, sizeof(view_layer->name));
+ BLI_uniquename(&scene->view_layers, view_layer, DATA_("ViewLayer"), '.', offsetof(ViewLayer, name), sizeof(view_layer->name));
+
+ if (scene->nodetree) {
+ bNode *node;
+ int index = BLI_findindex(&scene->view_layers, view_layer);
+
+ for (node = scene->nodetree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_R_LAYERS && node->id == NULL) {
+ if (node->custom1 == index)
+ BLI_strncpy(node->name, view_layer->name, NODE_MAXSTR);
+ }
+ }
+ }
+
+ /* fix all the animation data which may link to this */
+ BKE_animdata_fix_paths_rename_all(NULL, "view_layers", oldname, view_layer->name);
+
+ /* Dependency graph uses view layer name based lookups. */
+ DEG_id_tag_update(&scene->id, 0);
+}
+
/* LayerCollection */
/**