[Bf-blender-cvs] [62421470ee0] master: Nodes: remove group node forward compatibility with version 2.66

Brecht Van Lommel noreply at git.blender.org
Wed Apr 24 12:59:39 CEST 2019


Commit: 62421470ee09fb70f343eb9fd48b093316c8eea1
Author: Brecht Van Lommel
Date:   Sat Apr 20 20:25:21 2019 +0200
Branches: master
https://developer.blender.org/rB62421470ee09fb70f343eb9fd48b093316c8eea1

Nodes: remove group node forward compatibility with version 2.66

Forward compatibility with that version is already long gone, and removing
it means we can avoid running some complicated code on every file read/write.

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

M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenkernel/intern/node.c
M	source/blender/blenloader/intern/versioning_260.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/makesdna/DNA_node_types.h

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

diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 2433b856697..16655d9b060 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -27,7 +27,7 @@
  * \note Use #STRINGIFY() rather than defining with quotes.
  */
 #define BLENDER_VERSION 280
-#define BLENDER_SUBVERSION 58
+#define BLENDER_SUBVERSION 59
 /** Several breakages with 280, e.g. collections vs layers. */
 #define BLENDER_MINVERSION 280
 #define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 8a3f973ae5f..0fbddaf3597 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -2269,25 +2269,6 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
   else {
     BLI_snprintf(sock->identifier, MAX_NAME, "Output_%d", own_index);
   }
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
-  /* XXX forward compatibility:
-     * own_index is deprecated, but needs to be set here.
-     * Node sockets generally use the identifier string instead now,
-     * but reconstructing own_index in writefile.c would require parsing the identifier string.
-     */
-
-#  if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) || defined(__clang__)
-#    pragma GCC diagnostic push
-#    pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#  endif
-
-  sock->own_index = own_index;
-
-#  if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) || defined(__clang__)
-#    pragma GCC diagnostic pop
-#  endif
-
-#endif /* USE_NODE_COMPAT_CUSTOMNODES */
 
   sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
 
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 8010ca8b1b8..efe052c482f 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -2566,7 +2566,7 @@ void do_versions_after_linking_260(Main *bmain)
    * Note: this always runs, without it links with NULL fromnode and tonode remain
    * which causes problems.
    */
-  {
+  if (!MAIN_VERSION_ATLEAST(bmain, 266, 3)) {
     FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
       bNode *input_node = NULL, *output_node = NULL;
       int num_inputs = 0, num_outputs = 0;
@@ -2655,4 +2655,21 @@ void do_versions_after_linking_260(Main *bmain)
     }
     FOREACH_NODETREE_END;
   }
+
+  if (!MAIN_VERSION_ATLEAST(bmain, 280, 59)) {
+    /* From this point we no longer write incomplete links for forward
+     * compatibility with 2.66, we have to clean them up for all previous
+     * versions. */
+    FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+      bNodeLink *link, *next_link;
+
+      for (link = ntree->links.first; link; link = next_link) {
+        next_link = link->next;
+        if (link->fromnode == NULL || link->tonode == NULL) {
+          nodeRemLink(ntree, link);
+        }
+      }
+    }
+    FOREACH_NODETREE_END;
+  }
 }
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 4abe873403d..9a4e2adc0e3 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -167,10 +167,6 @@
 #include "BKE_subsurf.h"
 #include "BKE_workspace.h"
 
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
-#  include "NOD_socket.h" /* for sock->default_value data */
-#endif
-
 #include "BLO_blend_defs.h"
 #include "BLO_blend_validate.h"
 #include "BLO_readfile.h"
@@ -958,32 +954,8 @@ static void write_curvemapping(WriteData *wd, CurveMapping *cumap)
   write_curvemapping_curves(wd, cumap);
 }
 
-static void write_node_socket(WriteData *wd,
-                              bNodeTree *UNUSED(ntree),
-                              bNode *node,
-                              bNodeSocket *sock)
+static void write_node_socket(WriteData *wd, bNodeSocket *sock)
 {
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
-  /* forward compatibility code, so older blenders still open (not for undo) */
-  if (wd->use_memfile == false) {
-    sock->stack_type = 1;
-
-    if (node->type == NODE_GROUP) {
-      bNodeTree *ngroup = (bNodeTree *)node->id;
-      if (ngroup) {
-        /* for node groups: look up the deprecated groupsock pointer */
-        sock->groupsock = ntreeFindSocketInterface(ngroup, sock->in_out, sock->identifier);
-        BLI_assert(sock->groupsock != NULL);
-
-        /* node group sockets now use the generic identifier string to verify group nodes,
-         * old blender uses the own_index.
-         */
-        sock->own_index = sock->groupsock->own_index;
-      }
-    }
-  }
-#endif
-
   /* actual socket writing */
   writestruct(wd, DATA, bNodeSocket, 1, sock);
 
@@ -995,18 +967,8 @@ static void write_node_socket(WriteData *wd,
     writedata(wd, DATA, MEM_allocN_len(sock->default_value), sock->default_value);
   }
 }
-static void write_node_socket_interface(WriteData *wd, bNodeTree *UNUSED(ntree), bNodeSocket *sock)
+static void write_node_socket_interface(WriteData *wd, bNodeSocket *sock)
 {
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
-  /* forward compatibility code, so older blenders still open */
-  sock->stack_type = 1;
-
-  /* Reconstruct the deprecated default_value structs in socket interface DNA. */
-  if (sock->default_value == NULL && sock->typeinfo) {
-    node_socket_init_default_value(sock);
-  }
-#endif
-
   /* actual socket writing */
   writestruct(wd, DATA, bNodeSocket, 1, sock);
 
@@ -1039,10 +1001,10 @@ static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree)
     }
 
     for (sock = node->inputs.first; sock; sock = sock->next) {
-      write_node_socket(wd, ntree, node, sock);
+      write_node_socket(wd, sock);
     }
     for (sock = node->outputs.first; sock; sock = sock->next) {
-      write_node_socket(wd, ntree, node, sock);
+      write_node_socket(wd, sock);
     }
 
     for (link = node->internal_links.first; link; link = link->next) {
@@ -1126,10 +1088,10 @@ static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree)
   }
 
   for (sock = ntree->inputs.first; sock; sock = sock->next) {
-    write_node_socket_interface(wd, ntree, sock);
+    write_node_socket_interface(wd, sock);
   }
   for (sock = ntree->outputs.first; sock; sock = sock->next) {
-    write_node_socket_interface(wd, ntree, sock);
+    write_node_socket_interface(wd, sock);
   }
 }
 
@@ -3163,76 +3125,6 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree)
   }
 }
 
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
-static void customnodes_add_deprecated_data(Main *mainvar)
-{
-  FOREACH_NODETREE_BEGIN (mainvar, ntree, id) {
-    bNodeLink *link, *last_link = ntree->links.last;
-
-    /* only do this for node groups */
-    if (id != &ntree->id) {
-      continue;
-    }
-
-    /* Forward compatibility for group nodes: add links to node tree interface sockets.
-     * These links are invalid by new rules (missing node pointer)!
-     * They will be removed again in customnodes_free_deprecated_data,
-     * cannot do this directly lest bNodeLink pointer mapping becomes ambiguous.
-     * When loading files with such links in a new Blender version
-     * they will be removed as well.
-     */
-    for (link = ntree->links.first; link; link = link->next) {
-      bNode *fromnode = link->fromnode, *tonode = link->tonode;
-      bNodeSocket *fromsock = link->fromsock, *tosock = link->tosock;
-
-      /* check both sides of the link, to handle direct input-to-output links */
-      if (fromnode->type == NODE_GROUP_INPUT) {
-        fromnode = NULL;
-        fromsock = ntreeFindSocketInterface(ntree, SOCK_IN, fromsock->identifier);
-      }
-      /* only the active output node defines links */
-      if (tonode->type == NODE_GROUP_OUTPUT && (tonode->flag & NODE_DO_OUTPUT)) {
-        tonode = NULL;
-        tosock = ntreeFindSocketInterface(ntree, SOCK_OUT, tosock->identifier);
-      }
-
-      if (!fromnode || !tonode) {
-        /* Note: not using nodeAddLink here, it asserts existing node pointers */
-        bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "group node link");
-        tlink->fromnode = fromnode;
-        tlink->fromsock = fromsock;
-        tlink->tonode = tonode;
-        tlink->tosock = tosock;
-        tosock->link = tlink;
-        tlink->flag |= NODE_LINK_VALID;
-        BLI_addtail(&ntree->links, tlink);
-      }
-
-      /* don't check newly created compatibility links */
-      if (link == last_link) {
-        break;
-      }
-    }
-  }
-  FOREACH_NODETREE_END;
-}
-
-static void customnodes_free_deprecated_data(Main *mainvar)
-{
-  FOREACH_NODETREE_BEGIN (mainvar, ntree, id) {
-    bNodeLink *link, *next_link;
-
-    for (link = ntree->links.first; link; link = next_link) {
-      next_link = link->next;
-      if (link->fromnode == NULL || link->tonode == NULL) {
-        nodeRemLink(ntree, link);
-      }
-    }
-  }
-  FOREACH_NODETREE_END;
-}
-#endif
-
 static void write_brush(WriteData *wd, Brush *brush)
 {
   if (brush->id.us > 0 || wd->use_memfile) {
@@ -3867,14 +3759,6 @@ static bool write_file_handle(Main *mainvar,
 
   wd = mywrite_begin(ww, compare, current);
 
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
-  /* don't write compatibility data on undo */
-  if (!current) {
-    /* deprecated forward compat data is freed again below */
-    customnodes_add_deprecated_data(mainvar);
-  }
-#endif
-
   sprintf(buf,
           "BLENDER%c%c%.3d",
           (sizeof(void *) == 8) ? '-' : '_',
@@ -4067,17 +3951,6 @@ static bool write_file_handle(Main *mainvar,
    * so writing each time uses the same address and doesn't cause unnecessary undo overhead. */
   writedata(wd, DNA1, wd->sdna->data_len, wd->sdna->data);
 
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
-  /* compatibility data not created on undo */
-  if (!current) {
-    /* Ugly, forward compatibility code generates deprecated data during writing,
-     * this has to be freed again. Can not be done directly after writing, otherwise
-     * the data pointers could be reused and not be mapped correctly.
-     */
-    customnodes_free_deprecated_data(mainvar);
-  }
-#endif
-
   /* end of file */
   memset(&bhead, 0, sizeof(BHead

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list