Fix #154398: Unpacking an image via the N-panel in shader editor doesn't work

`image_from_context` returns null during poll check which prevents the
exec() callback. Add `edit_image` condition inside `node_context()`,
that way `image_from_context` returns valid image ID.

Pull Request: https://projects.blender.org/blender/blender/pulls/154439
This commit is contained in:
Pratik Borhade 2026-02-18 11:28:33 +01:00 • committed by Pratik Borhade
parent 1dee3778af
commit eb658361a4

View file

@ -1467,7 +1467,15 @@ static int /*eContextResult*/ node_context(const bContext *C,
}
return CTX_RESULT_OK;
}
if (CTX_data_equals(member, "edit_image")) {
if (bNode *node = bke::node_get_active(*snode->edittree)) {
if (ELEM(node->type_legacy, SH_NODE_TEX_IMAGE, SH_NODE_TEX_ENVIRONMENT)) {
Image *image = id_cast<Image *>(node->id);
CTX_data_id_pointer_set(result, &image->id);
return CTX_RESULT_OK;
}
}
}
return CTX_RESULT_MEMBER_NOT_FOUND;
}