Cleanup: Use const parameters for node poll functions
This requires a const cast in RNA, but it really is wrong to change the nodes and node trees in these callbacks.
This commit is contained in:
parent
d7dad425c0
commit
8c6fe60844
|
@ -299,12 +299,14 @@ typedef struct bNodeType {
|
|||
* when it's not just a dummy, that is, if it actually wants to access
|
||||
* the returned disabled-hint (null-check needed!).
|
||||
*/
|
||||
bool (*poll)(struct bNodeType *ntype, struct bNodeTree *nodetree, const char **r_disabled_hint);
|
||||
bool (*poll)(const struct bNodeType *ntype,
|
||||
const struct bNodeTree *nodetree,
|
||||
const char **r_disabled_hint);
|
||||
/** Can this node be added to a node tree?
|
||||
* \param r_disabled_hint: See `poll()`.
|
||||
*/
|
||||
bool (*poll_instance)(struct bNode *node,
|
||||
struct bNodeTree *nodetree,
|
||||
bool (*poll_instance)(const struct bNode *node,
|
||||
const struct bNodeTree *nodetree,
|
||||
const char **r_disabled_hint);
|
||||
|
||||
/* optional handling of link insertion */
|
||||
|
|
|
@ -4034,14 +4034,16 @@ static void node_type_base_defaults(bNodeType *ntype)
|
|||
}
|
||||
|
||||
/* allow this node for any tree type */
|
||||
static bool node_poll_default(bNodeType * /*ntype*/,
|
||||
bNodeTree * /*ntree*/,
|
||||
static bool node_poll_default(const bNodeType * /*ntype*/,
|
||||
const bNodeTree * /*ntree*/,
|
||||
const char ** /*disabled_hint*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool node_poll_instance_default(bNode *node, bNodeTree *ntree, const char **disabled_hint)
|
||||
static bool node_poll_instance_default(const bNode *node,
|
||||
const bNodeTree *ntree,
|
||||
const char **disabled_hint)
|
||||
{
|
||||
return node->typeinfo->poll(node->typeinfo, ntree, disabled_hint);
|
||||
}
|
||||
|
|
|
@ -1659,7 +1659,9 @@ char *rna_Node_ImageUser_path(const PointerRNA *ptr)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static bool rna_Node_poll(bNodeType *ntype, bNodeTree *ntree, const char **UNUSED(r_disabled_hint))
|
||||
static bool rna_Node_poll(const bNodeType *ntype,
|
||||
const bNodeTree *ntree,
|
||||
const char **UNUSED(r_disabled_hint))
|
||||
{
|
||||
extern FunctionRNA rna_Node_poll_func;
|
||||
|
||||
|
@ -1684,8 +1686,8 @@ static bool rna_Node_poll(bNodeType *ntype, bNodeTree *ntree, const char **UNUSE
|
|||
return visible;
|
||||
}
|
||||
|
||||
static bool rna_Node_poll_instance(bNode *node,
|
||||
bNodeTree *ntree,
|
||||
static bool rna_Node_poll_instance(const bNode *node,
|
||||
const bNodeTree *ntree,
|
||||
const char **UNUSED(disabled_info))
|
||||
{
|
||||
extern FunctionRNA rna_Node_poll_instance_func;
|
||||
|
@ -1696,7 +1698,7 @@ static bool rna_Node_poll_instance(bNode *node,
|
|||
void *ret;
|
||||
bool visible;
|
||||
|
||||
RNA_pointer_create(NULL, node->typeinfo->rna_ext.srna, node, &ptr); /* dummy */
|
||||
RNA_pointer_create(NULL, node->typeinfo->rna_ext.srna, (bNode *)node, &ptr); /* dummy */
|
||||
func = &rna_Node_poll_instance_func; /* RNA_struct_find_function(&ptr, "poll_instance"); */
|
||||
|
||||
RNA_parameter_list_create(&list, &ptr, func);
|
||||
|
@ -1711,8 +1713,8 @@ static bool rna_Node_poll_instance(bNode *node,
|
|||
return visible;
|
||||
}
|
||||
|
||||
static bool rna_Node_poll_instance_default(bNode *node,
|
||||
bNodeTree *ntree,
|
||||
static bool rna_Node_poll_instance_default(const bNode *node,
|
||||
const bNodeTree *ntree,
|
||||
const char **disabled_info)
|
||||
{
|
||||
/* use the basic poll function */
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
|
||||
#include "node_composite_util.hh"
|
||||
|
||||
bool cmp_node_poll_default(bNodeType * /*ntype*/, bNodeTree *ntree, const char **r_disabled_hint)
|
||||
bool cmp_node_poll_default(const bNodeType * /*ntype*/,
|
||||
const bNodeTree *ntree,
|
||||
const char **r_disabled_hint)
|
||||
{
|
||||
if (!STREQ(ntree->idname, "CompositorNodeTree")) {
|
||||
*r_disabled_hint = TIP_("Not a compositor node tree");
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
#define CMP_SCALE_MAX 12000
|
||||
|
||||
bool cmp_node_poll_default(struct bNodeType *ntype,
|
||||
struct bNodeTree *ntree,
|
||||
bool cmp_node_poll_default(const struct bNodeType *ntype,
|
||||
const struct bNodeTree *ntree,
|
||||
const char **r_disabled_hint);
|
||||
void cmp_node_update_default(struct bNodeTree *ntree, struct bNode *node);
|
||||
void cmp_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass);
|
||||
|
|
|
@ -277,8 +277,8 @@ static void node_copy_cryptomatte(bNodeTree * /*dst_ntree*/,
|
|||
dest_node->storage = dest_nc;
|
||||
}
|
||||
|
||||
static bool node_poll_cryptomatte(bNodeType * /*ntype*/,
|
||||
bNodeTree *ntree,
|
||||
static bool node_poll_cryptomatte(const bNodeType * /*ntype*/,
|
||||
const bNodeTree *ntree,
|
||||
const char **r_disabled_hint)
|
||||
{
|
||||
if (STREQ(ntree->idname, "CompositorNodeTree")) {
|
||||
|
|
|
@ -712,8 +712,8 @@ static void node_composit_init_rlayers(const bContext *C, PointerRNA *ptr)
|
|||
}
|
||||
}
|
||||
|
||||
static bool node_composit_poll_rlayers(bNodeType * /*ntype*/,
|
||||
bNodeTree *ntree,
|
||||
static bool node_composit_poll_rlayers(const bNodeType * /*ntype*/,
|
||||
const bNodeTree *ntree,
|
||||
const char **r_disabled_hint)
|
||||
{
|
||||
if (!STREQ(ntree->idname, "CompositorNodeTree")) {
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
#include "NOD_socket_search_link.hh"
|
||||
|
||||
static bool fn_node_poll_default(bNodeType * /*ntype*/,
|
||||
bNodeTree *ntree,
|
||||
static bool fn_node_poll_default(const bNodeType * /*ntype*/,
|
||||
const bNodeTree *ntree,
|
||||
const char **r_disabled_hint)
|
||||
{
|
||||
/* Function nodes are only supported in simulation node trees so far. */
|
||||
|
|
|
@ -41,7 +41,9 @@ std::optional<eCustomDataType> node_socket_to_custom_data_type(const bNodeSocket
|
|||
|
||||
} // namespace blender::nodes
|
||||
|
||||
bool geo_node_poll_default(bNodeType * /*ntype*/, bNodeTree *ntree, const char **r_disabled_hint)
|
||||
bool geo_node_poll_default(const bNodeType * /*ntype*/,
|
||||
const bNodeTree *ntree,
|
||||
const char **r_disabled_hint)
|
||||
{
|
||||
if (!STREQ(ntree->idname, "GeometryNodeTree")) {
|
||||
*r_disabled_hint = TIP_("Not a geometry node tree");
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
struct BVHTreeFromMesh;
|
||||
|
||||
void geo_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass);
|
||||
bool geo_node_poll_default(struct bNodeType *ntype,
|
||||
struct bNodeTree *ntree,
|
||||
bool geo_node_poll_default(const struct bNodeType *ntype,
|
||||
const struct bNodeTree *ntree,
|
||||
const char **r_disabled_hint);
|
||||
|
||||
namespace blender::nodes {
|
||||
|
|
|
@ -70,10 +70,12 @@ void node_group_label(const bNodeTree * /*ntree*/, const bNode *node, char *labe
|
|||
BLI_strncpy(label, (node->id) ? node->id->name + 2 : IFACE_("Missing Data-Block"), maxlen);
|
||||
}
|
||||
|
||||
bool node_group_poll_instance(bNode *node, bNodeTree *nodetree, const char **disabled_hint)
|
||||
bool node_group_poll_instance(const bNode *node,
|
||||
const bNodeTree *nodetree,
|
||||
const char **disabled_hint)
|
||||
{
|
||||
if (node->typeinfo->poll(node->typeinfo, nodetree, disabled_hint)) {
|
||||
bNodeTree *grouptree = (bNodeTree *)node->id;
|
||||
const bNodeTree *grouptree = (const bNodeTree *)node->id;
|
||||
if (grouptree) {
|
||||
return nodeGroupPoll(nodetree, grouptree, disabled_hint);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ void node_group_label(const struct bNodeTree *ntree,
|
|||
const struct bNode *node,
|
||||
char *label,
|
||||
int maxlen);
|
||||
bool node_group_poll_instance(struct bNode *node,
|
||||
struct bNodeTree *nodetree,
|
||||
bool node_group_poll_instance(const struct bNode *node,
|
||||
const struct bNodeTree *nodetree,
|
||||
const char **r_disabled_hint);
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
#include "RNA_access.h"
|
||||
|
||||
static bool node_undefined_poll(bNodeType * /*ntype*/,
|
||||
bNodeTree * /*nodetree*/,
|
||||
static bool node_undefined_poll(const bNodeType * /*ntype*/,
|
||||
const bNodeTree * /*nodetree*/,
|
||||
const char ** /*r_disabled_hint*/)
|
||||
{
|
||||
/* this type can not be added deliberately, it's just a placeholder */
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
|
||||
#include "node_exec.h"
|
||||
|
||||
bool sh_node_poll_default(bNodeType * /*ntype*/, bNodeTree *ntree, const char **r_disabled_hint)
|
||||
bool sh_node_poll_default(const bNodeType * /*ntype*/,
|
||||
const bNodeTree *ntree,
|
||||
const char **r_disabled_hint)
|
||||
{
|
||||
if (!STREQ(ntree->idname, "ShaderNodeTree")) {
|
||||
*r_disabled_hint = TIP_("Not a shader node tree");
|
||||
|
@ -24,8 +26,8 @@ bool sh_node_poll_default(bNodeType * /*ntype*/, bNodeTree *ntree, const char **
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool sh_fn_poll_default(bNodeType * /*ntype*/,
|
||||
bNodeTree *ntree,
|
||||
static bool sh_fn_poll_default(const bNodeType * /*ntype*/,
|
||||
const bNodeTree *ntree,
|
||||
const char **r_disabled_hint)
|
||||
{
|
||||
if (!STR_ELEM(ntree->idname, "ShaderNodeTree", "GeometryNodeTree")) {
|
||||
|
|
|
@ -63,8 +63,8 @@
|
|||
|
||||
#include "RNA_access.h"
|
||||
|
||||
bool sh_node_poll_default(struct bNodeType *ntype,
|
||||
struct bNodeTree *ntree,
|
||||
bool sh_node_poll_default(const struct bNodeType *ntype,
|
||||
const struct bNodeTree *ntree,
|
||||
const char **r_disabled_hint);
|
||||
void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass);
|
||||
void sh_fn_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "node_texture_util.hh"
|
||||
|
||||
bool tex_node_poll_default(bNodeType * /*ntype*/, bNodeTree *ntree, const char **r_disabled_hint)
|
||||
bool tex_node_poll_default(const bNodeType * /*ntype*/, const bNodeTree *ntree, const char **r_disabled_hint)
|
||||
{
|
||||
if (!STREQ(ntree->idname, "TextureNodeTree")) {
|
||||
*r_disabled_hint = TIP_("Not a texture node tree");
|
||||
|
|
|
@ -92,8 +92,8 @@ typedef struct TexDelegate {
|
|||
int type;
|
||||
} TexDelegate;
|
||||
|
||||
bool tex_node_poll_default(struct bNodeType *ntype,
|
||||
struct bNodeTree *ntree,
|
||||
bool tex_node_poll_default(const struct bNodeType *ntype,
|
||||
const struct bNodeTree *ntree,
|
||||
const char **r_disabled_hint);
|
||||
void tex_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass);
|
||||
|
||||
|
|
Loading…
Reference in New Issue