Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-10-06 04:59:26 +0300
committerCampbell Barton <campbell@blender.org>2022-10-06 05:07:16 +0300
commit63ed9550e94c9d054c632802d68000e35c6eb76a (patch)
tree42513ee9d36cd324aab03c3329fbc54e12fe2ea4 /release
parent68ea6c85abc6ce8d67f0a270314330a115dc9981 (diff)
Fix exception in bpy_extras.object_utils.object_data_add(..)
Adding object-data that doesn't support edit-mode would raise an exception when the "Enter Edit Mode" preferences was enabled. Other changes: - Don't attempt to enter edit-mode for library-data. - Support entering edit-mode for grease-pencil objects. Alternate fix for the issue raised by D15999.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/modules/bpy_extras/object_utils.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py
index ab678ba27c8..5275a83e062 100644
--- a/release/scripts/modules/bpy_extras/object_utils.py
+++ b/release/scripts/modules/bpy_extras/object_utils.py
@@ -142,8 +142,17 @@ def object_data_add(context, obdata, operator=None, name=None):
bpy.ops.object.mode_set(mode='EDIT')
else:
layer.objects.active = obj_new
- if obdata and context.preferences.edit.use_enter_edit_mode:
- bpy.ops.object.mode_set(mode='EDIT')
+ if context.preferences.edit.use_enter_edit_mode:
+ if obdata and obdata.library is None:
+ obtype = obj_new.type
+ mode = None
+ if obtype in {'ARMATURE', 'CURVE', 'CURVES', 'FONT', 'LATTICE', 'MESH', 'META', 'SURFACE'}:
+ mode = 'EDIT'
+ elif obtype == 'GPENCIL':
+ mode = 'EDIT_GPENCIL'
+
+ if mode is not None:
+ bpy.ops.object.mode_set(mode=mode)
return obj_new