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 <brecht@blender.org>2021-03-15 18:11:12 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-03-15 18:47:07 +0300
commitcd3fade2aaf74d1c3db345c13bd0122dc45d372f (patch)
treea87fb96829eecd8c7f138539ef26a196b1ab947a /intern/cycles/graph/node_type.h
parent3fdef12162f68a7f89a6f868f927fe8755c7bd20 (diff)
Fix Cycles rendering crash on OpenBSD
Static initialization order was not guaranteed to be correct for node base types. Now wrap all initialization in accessor functions to ensure the order is correct. Did not cause any known bug on Linux/macOS/Windows, but showed up on this platform.
Diffstat (limited to 'intern/cycles/graph/node_type.h')
-rw-r--r--intern/cycles/graph/node_type.h27
1 files changed, 19 insertions, 8 deletions
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 */