Python curve hook operators mess with selection (Probably only on Windows) #74888
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#74888
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 441.20
Blender Version
Broken: version: 2.83 (sub 9), branch: master, commit date: 2020-03-15 22:43, hash:
f06a6e92bc
Worked: I tried an older version which I know to have worked on my Linux machine at work a few days ago, and it still didn't work, so I suspect this issue is only present on Windows, or only on my computer. Let me know if you can reproduce.
Exact steps for others to reproduce the error
python_curve_select_bug.blend
Run the python script
curve_select_fail.py
.Hook modifiers get added. According to the code, the modifiers should correspond to each curve point. Instead, the result is random - most of the time, but not always, only the first point is hooked with all of the modifiers.
Run the python script
why_index_error.py
It index errors. If you remove the last line of code, it works. The last line of code shouldn't affect the curve's indicies, so this can't be right.
LYnrN6gUUu.mp4
I could really use a workaround until this is fixed.
Added subscriber: @Mets
Added subscribers: @ideasman42, @mano-wii
Changed status from 'Needs Triage' to: 'Confirmed'
The problem is quite complex.
The operator
OBJECT_OT_hook_add_selob
callsED_curve_editnurb_load
which creates anothercu->nurb
and free the old one.But the old
cu->nurb
is already referenced by aPyObject
of typepyrna_prop_collection_Type
with pointer inited inrna_Curve_splines_begin
.The ideal would be, when freeing the pointer, to call
RNA_POINTER_INVALIDATE(nu_ptr)
for the originalPointerRNA
.But the question is, how to find this
PointerRNA
in the operator?@ideasman42, we need an RNA/CPython expert here.
Or maybe we don't even need free
cu->nurb
Thanks for looking into it! Were you able to reproduce it on Linux as well? I could swear that this worked on my work computer just a few days ago... I will check if I get the chance, but working from home atm >.>.
In the meanwhile, based on your description of the issue, I managed to work around it by re-grabbing my reference to the object, spline and curve points after running the Add Hook operator.
As far as I can see, there is no simple solution to this.
I don't think it will be resolved anytime soon.
No worries. For anyone else running into this, some elaboration on the workaround:
This will (or might) fail:
Whereas this should work:
Just refresh your reference to curve_ob(and therefore curve_ob.data) after using the operator.
I have since found out that there is no need to use bpy.ops here, thanks to
3f788eacee
. Hook modifiers can be assigned vertices withmy_hook_modifier.vertex_indices_set([0, 1, 2])
. A much better workaround than what I posted previously, although it does involve reshuffling code a bit more.I feel like there's no reason to have to call
bpy.ops.object.hook_add_selob()
from Python anymore. With that in mind I bumped down the priority, but maybe this could even be closed, not sure.Changed status from 'Confirmed' to: 'Archived'
Closing since I don't think it's reasonable to consider operators re-allocation of data a bug in the Python API (although from the users perspective I realize it's not very nice).