Fix: Viewer node crashes when the editor is pinned and has no Object ID #107737
|
@ -24,6 +24,9 @@ static void viewer_path_for_geometry_node(const SpaceNode &snode,
|
|||
const bNode &node,
|
||||
ViewerPath &r_dst)
|
||||
{
|
||||
/* Only valid if the node space has a context object. */
|
||||
BLI_assert(snode.id != nullptr && GS(snode.id->name) == ID_OB);
|
||||
|
||||
|
||||
BKE_viewer_path_init(&r_dst);
|
||||
|
||||
Object *ob = reinterpret_cast<Object *>(snode.id);
|
||||
|
@ -87,7 +90,9 @@ void activate_geometry_node(Main &bmain, SpaceNode &snode, bNode &node)
|
|||
}
|
||||
ViewerPath new_viewer_path{};
|
||||
BLI_SCOPED_DEFER([&]() { BKE_viewer_path_clear(&new_viewer_path); });
|
||||
viewer_path_for_geometry_node(snode, node, new_viewer_path);
|
||||
if (snode.id != nullptr && GS(snode.id->name) == ID_OB) {
|
||||
viewer_path_for_geometry_node(snode, node, new_viewer_path);
|
||||
}
|
||||
|
||||
bool found_view3d_with_enabled_viewer = false;
|
||||
View3D *any_view3d_without_viewer = nullptr;
|
||||
|
@ -341,6 +346,11 @@ bool is_active_geometry_nodes_viewer(const bContext &C,
|
|||
|
||||
bNode *find_geometry_nodes_viewer(const ViewerPath &viewer_path, SpaceNode &snode)
|
||||
{
|
||||
/* Viewer path is only valid if the context object is set. */
|
||||
if (snode.id == nullptr || GS(snode.id->name) != ID_OB) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::optional<ViewerPathForGeometryNodesViewer> parsed_viewer_path =
|
||||
parse_geometry_nodes_viewer(viewer_path);
|
||||
if (!parsed_viewer_path.has_value()) {
|
||||
|
|
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.