Performing a Translate Operation after switching the context area crashes Blender

Hey, I hope someone has an idea as to whats going on because this has been throwing me off for a while.

Ive been moving plugin code off the Toolshelf in the 3D view since Blender 2.8’s UI design has changed, and some of my operations now reside in the Render menu. As they rely on a 3D View being the current context to operate within it for certain tasks, I have to switch the context area. However, doing a translate operation once changed causes Blender to crash and I haven’t been able to work out why as the crash logs provide little useful information.

I’ve included a basic addon you can add to Blender to test it yourself, the button will appear under the Render menu in the Properties panel. (1.7 KB)

It’s two simple lines that do it:

bpy.context.area.type = 'VIEW_3D'

Any help would be greatly appreciated!

Looks like a bug with blender trying to access a freed region. Passing any arbitrary region from a different area in the override seems to be fine.

import bpy
context = bpy.context

for area in context.screen.areas:
    if area != context.area:

override = {'region': area.regions[0]}

context.area.type = 'VIEW_3D'

Thanks for the help, i’m unable to get your override suggestion working though - there’s no override parameter for the operator. I’m also not sure what the purpose of the break is…

Override arguments are implied when operators are called with the first positional argument as a dictionary. If you need to pass other arguments, the order is context_dict >> exec_type >>**kwargs.

To break is to stop looping. When the conditional evaluates to true I exit the loop with the area using break. The idea is to get an area that is not context.area, since that one has a faulty region.

1 Like

Ah, I get it now, the lack of an explicit area value assignment threw me off.

Thanks for your patience :slight_smile: