Page MenuHome

Python operator "Brush Edit" crashes
Closed, InvalidPublic


The following code makes Blender to crash :

import bpy

area = bpy.context.area
old_type = area.type
area.type = "VIEW_3D"

bpy.ops.particle.brush_edit(stroke=[{"name":"", "location":(0, 0, 0), "mouse":(0, 0), "pressure":0, "size":0, "pen_flip":False, "time":0, "is_start":False}])

area.type = old_type

I'm doing this to set the is_editable flag of a Particle System to True.

Event Timeline

Sergey Sharybin (sergey) lowered the priority of this task from 90 to 30.Jul 6 2015, 11:40 AM

Please follow the report bug guidelines and provide:

  • Operation system you're using
  • Exact blender version which crashes for you
  • Blend file which demonstrates the issue

I can not reproduce any crashes on Linux with default cube and hait added to it.

tested on several 2.74 and 2.75 (own build and official build.)
Linux centos 6

and here is the blend file with the above code just paste into the script editor...

run the script should make blender crash


Sergey Sharybin (sergey) raised the priority of this task from 30 to 50.Jul 6 2015, 7:05 PM

Now can see the crash.

@Campbell Barton (campbellbarton), @Antonis Ryakiotakis (psy-fi), guess it's not always possible to support operations like this, but at the same time would be nice if blender doesn't crash. Think some NULL-pointer check or extra poll-function checks would solve the issue.

if using this operator is not possible, beside the facts that it shouldn't crash, we would also need a python function to set the hair system in edited mode via python.
for now, and AFAIK only this operator can set it in this mode.



Campbell Barton (campbellbarton) changed the task status from Unknown Status to Unknown Status.Aug 26 2015, 11:19 AM

The crash here is caused by the area changing, but not the region.
(So the area is from the 3D view, but there is no RegionView3D)

Even though it would be good to prevent crashes. This is quite a *broken* context, which would involve adding checks to many viewport operators.

For now this is something we just don't support, If you set the region too, you may be able to get it working... but changing context like this just doesn't work so well at the moment.