diff options
Diffstat (limited to 'intern/cycles/graph')
-rw-r--r-- | intern/cycles/graph/node_type.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/graph/node_type.h | 27 | ||||
-rw-r--r-- | intern/cycles/graph/node_xml.cpp | 4 |
3 files changed, 22 insertions, 11 deletions
diff --git a/intern/cycles/graph/node_type.cpp b/intern/cycles/graph/node_type.cpp index d1eadf21b1b..4efbd6725ee 100644 --- a/intern/cycles/graph/node_type.cpp +++ b/intern/cycles/graph/node_type.cpp @@ -154,7 +154,7 @@ void NodeType::register_input(ustring name, int struct_offset, const void *default_value, const NodeEnum *enum_values, - const NodeType **node_type, + const NodeType *node_type, int flags, int extra_flags) { diff --git a/intern/cycles/graph/node_type.h b/intern/cycles/graph/node_type.h index 3b9b3007099..2a741d9b06f 100644 --- a/intern/cycles/graph/node_type.h +++ b/intern/cycles/graph/node_type.h @@ -87,7 +87,7 @@ struct SocketType { int struct_offset; const void *default_value; const NodeEnum *enum_values; - const NodeType **node_type; + const NodeType *node_type; int flags; ustring ui_name; SocketModifiedFlags modified_flag_bit; @@ -115,7 +115,7 @@ struct NodeType { int struct_offset, const void *default_value, const NodeEnum *enum_values = NULL, - const NodeType **node_type = NULL, + const NodeType *node_type = NULL, int flags = 0, int extra_flags = 0); void register_output(ustring name, ustring ui_name, SocketType::Type type); @@ -140,27 +140,38 @@ struct NodeType { static unordered_map<ustring, NodeType, ustringHash> &types(); }; -/* Node Definition Macros */ +/* Node Definition Macros + * + * Node we use accessor to get node types to ensure correct static + * initialization order. */ #define NODE_DECLARE \ + static const NodeType *get_node_type(); \ template<typename T> static const NodeType *register_type(); \ - static Node *create(const NodeType *type); \ - static const NodeType *node_type; + static Node *create(const NodeType *type); #define NODE_DEFINE(structname) \ - const NodeType *structname::node_type = structname::register_type<structname>(); \ Node *structname::create(const NodeType *) \ { \ return new structname(); \ } \ + const NodeType *structname::get_node_type() \ + { \ + static const NodeType *node_type = register_type<structname>(); \ + return node_type; \ + } \ template<typename T> const NodeType *structname::register_type() #define NODE_ABSTRACT_DECLARE \ template<typename T> static const NodeType *register_base_type(); \ - static const NodeType *node_base_type; + static const NodeType *get_node_base_type(); #define NODE_ABSTRACT_DEFINE(structname) \ - const NodeType *structname::node_base_type = structname::register_base_type<structname>(); \ + const NodeType *structname::get_node_base_type() \ + { \ + static const NodeType *node_base_type = register_base_type<structname>(); \ + return node_base_type; \ + } \ template<typename T> const NodeType *structname::register_base_type() /* Sock Definition Macros */ diff --git a/intern/cycles/graph/node_xml.cpp b/intern/cycles/graph/node_xml.cpp index d333400cc4a..43462662b6a 100644 --- a/intern/cycles/graph/node_xml.cpp +++ b/intern/cycles/graph/node_xml.cpp @@ -200,7 +200,7 @@ void xml_read_node(XMLReader &reader, Node *node, xml_node xml_node) map<ustring, Node *>::iterator it = reader.node_map.find(value); if (it != reader.node_map.end()) { Node *value_node = it->second; - if (value_node->is_a(*(socket.node_type))) + if (value_node->is_a(socket.node_type)) node->set(socket, it->second); } break; @@ -215,7 +215,7 @@ void xml_read_node(XMLReader &reader, Node *node, xml_node xml_node) map<ustring, Node *>::iterator it = reader.node_map.find(ustring(tokens[i])); if (it != reader.node_map.end()) { Node *value_node = it->second; - value[i] = (value_node->is_a(*(socket.node_type))) ? value_node : NULL; + value[i] = (value_node->is_a(socket.node_type)) ? value_node : NULL; } else { value[i] = NULL; |