[Bf-blender-cvs] [7b528b2a3ad] blender-v2.92-release: Fix T84920: Crash undoing object activation in the outliner

Campbell Barton noreply at git.blender.org
Fri Jan 22 02:41:09 CET 2021


Commit: 7b528b2a3ad33b3ad7328213669d8179528e254b
Author: Campbell Barton
Date:   Fri Jan 22 11:33:33 2021 +1100
Branches: blender-v2.92-release
https://developer.blender.org/rB7b528b2a3ad33b3ad7328213669d8179528e254b

Fix T84920: Crash undoing object activation in the outliner

Regression from d8992192e5512380f57433df113f3e3f8b22f7cb
The original code relied on having a separate edit-object pointer
than the active object.

Use a utility function to avoid code duplication as there are
other areas that have similar functionality.

===================================================================

M	source/blender/editors/include/ED_object.h
M	source/blender/editors/object/object_select.c
M	source/blender/editors/space_outliner/outliner_select.c

===================================================================

diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 1fbc1339aa5..7ba2992b8fe 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -173,6 +173,7 @@ void ED_object_parent_clear(struct Object *ob, const int type);
 
 void ED_object_base_select(struct Base *base, eObjectSelect_Mode mode);
 void ED_object_base_activate(struct bContext *C, struct Base *base);
+void ED_object_base_activate_with_mode_exit_if_needed(struct bContext *C, struct Base *base);
 void ED_object_base_active_refresh(struct Main *bmain,
                                    struct Scene *scene,
                                    struct ViewLayer *view_layer);
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index ab404f0a72d..ede0a92cede 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -143,6 +143,21 @@ void ED_object_base_activate(bContext *C, Base *base)
   ED_object_base_active_refresh(CTX_data_main(C), scene, view_layer);
 }
 
+void ED_object_base_activate_with_mode_exit_if_needed(bContext *C, Base *base)
+{
+  ViewLayer *view_layer = CTX_data_view_layer(C);
+
+  /* Currently we only need to be concerned with edit-mode. */
+  Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
+  if (obedit) {
+    Object *ob = base->object;
+    if (((ob->mode & OB_MODE_EDIT) == 0) || (obedit->type != ob->type)) {
+      ED_object_editmode_exit(C, EM_FREEDATA);
+    }
+  }
+  ED_object_base_activate(C, base);
+}
+
 bool ED_object_base_deselect_all_ex(ViewLayer *view_layer,
                                     View3D *v3d,
                                     int action,
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index f8812ff5970..600047c4b11 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -398,14 +398,10 @@ static eOLDrawState tree_element_set_active_object(bContext *C,
     }
 
     if (set != OL_SETSEL_NONE) {
-      ED_object_base_activate(C, base); /* adds notifier */
+      ED_object_base_activate_with_mode_exit_if_needed(C, base); /* adds notifier */
       DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
       WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
     }
-
-    if (ob != OBEDIT_FROM_VIEW_LAYER(view_layer)) {
-      ED_object_editmode_exit(C, EM_FREEDATA);
-    }
   }
   return OL_DRAWSEL_NORMAL;
 }



More information about the Bf-blender-cvs mailing list