Fix T89982: Geometry Nodes: 'New' Button tries to create node_tree on active modifier, rather than button context

When done from the Properties Editor, the context's modifier should be
used (this is where the button is located), when done from elsewhere,
the active modifier is still the way to go (since the context modifier is
not available then)

Maniphest Tasks: T89982

Differential Revision: https://developer.blender.org/D11972
This commit is contained in:
Philipp Oeser 2021-07-20 13:47:45 +02:00
parent 83b6fcc70c
commit 3e29175af3
Notes: blender-bot 2023-02-14 05:37:19 +01:00
Referenced by issue #88449, Blender LTS: Maintenance Task 2.93
Referenced by issue #89982, Geometry Nodes: 'New' Button tries to create node_tree on active modifier, rather than button context
1 changed files with 4 additions and 1 deletions

View File

@ -81,7 +81,10 @@ class NewGeometryNodeTreeAssign(Operator):
return geometry_modifier_poll(context)
def execute(self, context):
modifier = context.object.modifiers.active
if context.area.type == 'PROPERTIES':
modifier = context.modifier
else:
modifier = context.object.modifiers.active
if not modifier:
return {'CANCELLED'}