Cleanup: Const correctness for node find functions

You shouldn't be able to retrieve a mutable node from a const node tree
or a mutable socket from a const node. Use const_cast in one place in
order to correct this without duplicating the function, which is still
awkward in the C-API.
This commit is contained in:
2022-12-05 11:37:55 -06:00
parent ca2ca0ce5d
commit 2ce6ac462b
3 changed files with 8 additions and 8 deletions

View File

@@ -1455,7 +1455,7 @@ const char *nodeSocketTypeLabel(const bNodeSocketType *stype)
return stype->label[0] != '\0' ? stype->label : RNA_struct_ui_name(stype->ext_socket.srna);
}
bNodeSocket *nodeFindSocket(const bNode *node, eNodeSocketInOut in_out, const char *identifier)
bNodeSocket *nodeFindSocket(bNode *node, eNodeSocketInOut in_out, const char *identifier)
{
const ListBase *sockets = (in_out == SOCK_IN) ? &node->inputs : &node->outputs;
LISTBASE_FOREACH (bNodeSocket *, sock, sockets) {
@@ -3437,7 +3437,7 @@ void ntreeRemoveSocketInterface(bNodeTree *ntree, bNodeSocket *sock)
/* ************ find stuff *************** */
bNode *ntreeFindType(const bNodeTree *ntree, int type)
bNode *ntreeFindType(bNodeTree *ntree, int type)
{
if (ntree) {
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {