[Bf-blender-cvs] [a392609ab61] master: Cleanup: Move function to versioning_common.cc

Hans Goudey noreply at git.blender.org
Tue Sep 7 20:28:22 CEST 2021


Commit: a392609ab612236401b335f5c7f2790f60a4f765
Author: Hans Goudey
Date:   Tue Sep 7 13:28:14 2021 -0500
Branches: master
https://developer.blender.org/rBa392609ab612236401b335f5c7f2790f60a4f765

Cleanup: Move function to versioning_common.cc

===================================================================

M	source/blender/blenloader/intern/versioning_290.c
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/blenloader/intern/versioning_common.cc
M	source/blender/blenloader/intern/versioning_common.h

===================================================================

diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index b217850e119..cb7a8ad592a 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -829,33 +829,6 @@ static void do_versions_strip_cache_settings_recursive(const ListBase *seqbase)
   }
 }
 
-static void version_node_socket_name(bNodeTree *ntree,
-                                     const int node_type,
-                                     const char *old_name,
-                                     const char *new_name)
-{
-  LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
-    if (node->type == node_type) {
-      LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
-        if (STREQ(socket->name, old_name)) {
-          strcpy(socket->name, new_name);
-        }
-        if (STREQ(socket->identifier, old_name)) {
-          strcpy(socket->identifier, new_name);
-        }
-      }
-      LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) {
-        if (STREQ(socket->name, old_name)) {
-          strcpy(socket->name, new_name);
-        }
-        if (STREQ(socket->identifier, old_name)) {
-          strcpy(socket->identifier, new_name);
-        }
-      }
-    }
-  }
-}
-
 static void version_node_join_geometry_for_multi_input_socket(bNodeTree *ntree)
 {
   LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) {
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 13577164f20..f050de6e6e9 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -526,33 +526,6 @@ static void version_switch_node_input_prefix(Main *bmain)
   FOREACH_NODETREE_END;
 }
 
-static void version_node_socket_name(bNodeTree *ntree,
-                                     const int node_type,
-                                     const char *old_name,
-                                     const char *new_name)
-{
-  LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
-    if (node->type == node_type) {
-      LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
-        if (STREQ(socket->name, old_name)) {
-          strcpy(socket->name, new_name);
-        }
-        if (STREQ(socket->identifier, old_name)) {
-          strcpy(socket->identifier, new_name);
-        }
-      }
-      LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) {
-        if (STREQ(socket->name, old_name)) {
-          strcpy(socket->name, new_name);
-        }
-        if (STREQ(socket->identifier, old_name)) {
-          strcpy(socket->identifier, new_name);
-        }
-      }
-    }
-  }
-}
-
 static bool replace_bbone_len_scale_rnapath(char **p_old_path, int *p_index)
 {
   char *old_path = *p_old_path;
diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc
index 208c02b60d1..3f13d1ec12e 100644
--- a/source/blender/blenloader/intern/versioning_common.cc
+++ b/source/blender/blenloader/intern/versioning_common.cc
@@ -22,6 +22,7 @@
 
 #include <cstring>
 
+#include "DNA_node_types.h"
 #include "DNA_screen_types.h"
 
 #include "BLI_listbase.h"
@@ -85,3 +86,30 @@ ID *do_versions_rename_id(Main *bmain,
   }
   return id;
 }
+
+void version_node_socket_name(bNodeTree *ntree,
+                              const int node_type,
+                              const char *old_name,
+                              const char *new_name)
+{
+  LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
+    if (node->type == node_type) {
+      LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
+        if (STREQ(socket->name, old_name)) {
+          BLI_strncpy(socket->name, new_name, sizeof(socket->name));
+        }
+        if (STREQ(socket->identifier, old_name)) {
+          BLI_strncpy(socket->identifier, new_name, sizeof(socket->name));
+        }
+      }
+      LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) {
+        if (STREQ(socket->name, old_name)) {
+          BLI_strncpy(socket->name, new_name, sizeof(socket->name));
+        }
+        if (STREQ(socket->identifier, old_name)) {
+          BLI_strncpy(socket->identifier, new_name, sizeof(socket->name));
+        }
+      }
+    }
+  }
+}
diff --git a/source/blender/blenloader/intern/versioning_common.h b/source/blender/blenloader/intern/versioning_common.h
index 47e0b74a3e4..c1fe2b591cd 100644
--- a/source/blender/blenloader/intern/versioning_common.h
+++ b/source/blender/blenloader/intern/versioning_common.h
@@ -23,6 +23,7 @@
 struct ARegion;
 struct ListBase;
 struct Main;
+struct bNodeTree;
 
 #ifdef __cplusplus
 extern "C" {
@@ -38,6 +39,11 @@ ID *do_versions_rename_id(Main *bmain,
                           const char *name_src,
                           const char *name_dst);
 
+void version_node_socket_name(struct bNodeTree *ntree,
+                              const int node_type,
+                              const char *old_name,
+                              const char *new_name);
+
 #ifdef __cplusplus
 }
 #endif



More information about the Bf-blender-cvs mailing list