Fix: Viewer node crashes when the editor is pinned and has no Object ID #107737
|
@ -26,34 +26,36 @@ static void viewer_path_for_geometry_node(const SpaceNode &snode,
|
|||
{
|
||||
BKE_viewer_path_init(&r_dst);
|
||||
|
||||
Object *ob = reinterpret_cast<Object *>(snode.id);
|
||||
IDViewerPathElem *id_elem = BKE_viewer_path_elem_new_id();
|
||||
id_elem->id = &ob->id;
|
||||
BLI_addtail(&r_dst.path, id_elem);
|
||||
if (snode.id != nullptr && GS(snode.id->name) == ID_OB) {
|
||||
|
||||
Object *ob = reinterpret_cast<Object *>(snode.id);
|
||||
IDViewerPathElem *id_elem = BKE_viewer_path_elem_new_id();
|
||||
id_elem->id = &ob->id;
|
||||
BLI_addtail(&r_dst.path, id_elem);
|
||||
|
||||
NodesModifierData *modifier = nullptr;
|
||||
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
|
||||
if (md->type != eModifierType_Nodes) {
|
||||
continue;
|
||||
NodesModifierData *modifier = nullptr;
|
||||
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
|
||||
if (md->type != eModifierType_Nodes) {
|
||||
continue;
|
||||
}
|
||||
NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
|
||||
if (nmd->node_group != snode.nodetree) {
|
||||
continue;
|
||||
}
|
||||
if (snode.flag & SNODE_PIN) {
|
||||
/* If the node group is pinned, use the first matching modifier. This can be improved by
|
||||
* storing the modifier name in the node editor when the context is pinned. */
|
||||
modifier = nmd;
|
||||
break;
|
||||
}
|
||||
if (md->flag & eModifierFlag_Active) {
|
||||
modifier = nmd;
|
||||
}
|
||||
}
|
||||
NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
|
||||
if (nmd->node_group != snode.nodetree) {
|
||||
continue;
|
||||
if (modifier != nullptr) {
|
||||
ModifierViewerPathElem *modifier_elem = BKE_viewer_path_elem_new_modifier();
|
||||
modifier_elem->modifier_name = BLI_strdup(modifier->modifier.name);
|
||||
BLI_addtail(&r_dst.path, modifier_elem);
|
||||
}
|
||||
if (snode.flag & SNODE_PIN) {
|
||||
/* If the node group is pinned, use the first matching modifier. This can be improved by
|
||||
* storing the modifier name in the node editor when the context is pinned. */
|
||||
modifier = nmd;
|
||||
break;
|
||||
}
|
||||
if (md->flag & eModifierFlag_Active) {
|
||||
modifier = nmd;
|
||||
}
|
||||
}
|
||||
if (modifier != nullptr) {
|
||||
ModifierViewerPathElem *modifier_elem = BKE_viewer_path_elem_new_modifier();
|
||||
modifier_elem->modifier_name = BLI_strdup(modifier->modifier.name);
|
||||
BLI_addtail(&r_dst.path, modifier_elem);
|
||||
}
|
||||
|
||||
Vector<const bNodeTreePath *, 16> tree_path = snode.treepath;
|
||||
|
|
Loading…
Reference in New Issue
Better check for this in the caller and only add an assert here. It's not possible to build a viewer path for a geometry node when parts of the context path (including the object and modifier) are missing.