Fix T77548: Crash when using Add Object Tool with Normal Orientation and zero objects in scene

The crash is caused by the fact that a NULL Object pointer is passed to
calculate the transform orientation, which has been set to normal.

A check has been include to detect the same.

Differential Revision: https://developer.blender.org/D7951
This commit is contained in:
Deep Majumder 2020-08-05 15:34:12 -03:00 committed by Germano Cavalcante
parent f3e724b93d
commit c323f3e90a
Notes: blender-bot 2023-02-14 06:49:57 +01:00
Referenced by issue #77548, Crash when using Interactive Mesh Tool with Normal Orientation and zero objects in scene.
1 changed files with 2 additions and 2 deletions

View File

@ -467,14 +467,14 @@ short ED_transform_calc_orientation_from_type_ex(const bContext *C,
return V3D_ORIENT_GLOBAL;
}
case V3D_ORIENT_GIMBAL: {
if (gimbal_axis(ob, r_mat)) {
if (ob && gimbal_axis(ob, r_mat)) {
return V3D_ORIENT_GIMBAL;
}
/* if not gimbal, fall through to normal */
ATTR_FALLTHROUGH;
}
case V3D_ORIENT_NORMAL: {
if (obedit || ob->mode & OB_MODE_POSE) {
if (obedit || (ob && ob->mode & OB_MODE_POSE)) {
ED_getTransformOrientationMatrix(C, r_mat, pivot_point);
return V3D_ORIENT_NORMAL;
}