Page MenuHome

Outliner crash when selecting object being in armature editmode [modeswitch]
Closed, ResolvedPublic

Description

System Information
Operating system: Windows-10-10.0.17134 64 Bits
Graphics card: GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 419.67

Blender Version
Broken: version: 2.80 (sub 52), branch: master, commit date: 2019-03-28 21:08, hash: rB42dd888b98b5
Worked: (optional)

Short description of error
Blender 2.8 beta abruptly shuts down (ie. crashes) if you open attached model and click on pencil-mesh in Outliner!

Event Timeline

Philipp Oeser (lichtwerk) triaged this task as Confirmed, Medium priority.Mar 29 2019, 10:03 AM

Confirmed, checking...

Happens when you are in armature editmode (not in posemode) and click on another object (not object data).
This will switch to objectmode (thus editbones are not valid anymore).

  • works fine if you are in posemode [and switch to objectmode from there]
  • works fine if you are in editmode and select the pencil mesh datablock [still in editmode then]

got a bandaid fix (since in this case we can check for obedit later):

1
2
3diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
4index 5ace2c291e0..faca9668db3 100644
5--- a/source/blender/editors/space_outliner/outliner_select.c
6+++ b/source/blender/editors/space_outliner/outliner_select.c
7@@ -691,13 +691,16 @@ static void tree_element_active_ebone__sel(bContext *C, Object *obedit, bArmatur
8 static eOLDrawState tree_element_active_ebone(
9 bContext *C, TreeElement *te, TreeStoreElem *UNUSED(tselem), const eOLSetState set, bool recursive)
10 {
11- Object *obedit = CTX_data_edit_object(C);
12- BLI_assert(obedit != NULL);
13- bArmature *arm = obedit->data;
14 EditBone *ebone = te->directdata;
15 eOLDrawState status = OL_DRAWSEL_NONE;
16
17 if (set != OL_SETSEL_NONE) {
18+ /* obedit can be NULL if we just selected another object
19+ * (thus having switched to objecmode) */
20+ Object *obedit = CTX_data_edit_object(C);
21+ BLI_assert(obedit != NULL);
22+ bArmature *arm = obedit->data;
23+
24 if (set == OL_SETSEL_NORMAL) {
25 if (!(ebone->flag & BONE_HIDDEN_A)) {
26 ED_armature_edit_deselect_all(obedit);

But there are other glitches as well (after selecting the Pencil):

  • Armature goes completely invisible [will have to check why that is]
  • Bone still draws as active (with a circle around the icon) which should only be the the case if the Armature is really

Will check the two "works fine" cases mentioned above (and will also check if we rebuild the tree on mode changes...)

Philipp Oeser (lichtwerk) renamed this task from Blender 2.8 Beta Crashes to Outliner crash when selecting object being in armature editmode [modeswitch].Mar 29 2019, 11:38 AM

Hm, just found out about rBa01244cade1c, T55246 (needs another round of thinking...)

Still confused actually.
There is also the case where tree_element_active_ebone (where the above assert happens) acts up in case of multi-armature select.
It just feels weird to use CTX_data_edit_object(C) here?
This will give us the active edit object, but in the file below this will be the same armature for all three selected armatures [which are all different].
This will lead to erratic selection behaviour, see:

try slecting different bones in different armatures from the outliner here, only the active ["03"] armature will select/deselect correctly, if you are selecting bones in "01" or "02" selection will act up [bones not being deselected etc]

I had another go at this and tried to not rely on CTX_data_edit_object(C), but instead use the armature directly from tselem... getting the corresponding object is a bit weak, but...
This will prevent mentioned crash and also improves upon selection from the outliner (I've also made sure all bones from other armatures are deselected, matching selection in 3dview...)

1
2
3diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
4index 5ace2c291e0..0fb2a3f9f87 100644
5--- a/source/blender/editors/space_outliner/outliner_select.c
6+++ b/source/blender/editors/space_outliner/outliner_select.c
7@@ -23,6 +23,8 @@
8
9 #include <stdlib.h>
10
11+#include "MEM_guardedalloc.h"
12+
13 #include "DNA_armature_types.h"
14 #include "DNA_collection_types.h"
15 #include "DNA_light_types.h"
16@@ -689,18 +691,36 @@ static void tree_element_active_ebone__sel(bContext *C, Object *obedit, bArmatur
17 WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, obedit);
18 }
19 static eOLDrawState tree_element_active_ebone(
20- bContext *C, TreeElement *te, TreeStoreElem *UNUSED(tselem), const eOLSetState set, bool recursive)
21+ bContext *C, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive)
22 {
23- Object *obedit = CTX_data_edit_object(C);
24- BLI_assert(obedit != NULL);
25- bArmature *arm = obedit->data;
26+ bArmature *arm = (bArmature *)tselem->id;
27+ ViewLayer *view_layer = CTX_data_view_layer(C);
28+ View3D *v3d = CTX_wm_view3d(C);
29+ uint objects_len = 0;
30+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, v3d, &objects_len);
31+ Object *obedit = NULL;
32+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
33+ obedit = objects[ob_index];
34+ if (obedit->data == arm) {
35+ break;
36+ }
37+ }
38+ MEM_freeN(objects);
39+ if (obedit == NULL) {
40+ printf("warning, still no obedit...\n");
41+ };
42+
43 EditBone *ebone = te->directdata;
44 eOLDrawState status = OL_DRAWSEL_NONE;
45
46 if (set != OL_SETSEL_NONE) {
47 if (set == OL_SETSEL_NORMAL) {
48 if (!(ebone->flag & BONE_HIDDEN_A)) {
49- ED_armature_edit_deselect_all(obedit);
50+ uint bases_len = 0;
51+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, v3d, &bases_len);
52+ ED_armature_edit_deselect_all_multi_ex(bases, bases_len);
53+ MEM_freeN(bases);
54+
55 tree_element_active_ebone__sel(C, obedit, arm, ebone, true);
56 status = OL_DRAWSEL_NORMAL;
57 }

I think this one is actually for @Campbell Barton (campbellbarton) to check on?

Brecht Van Lommel (brecht) raised the priority of this task from Confirmed, Medium to Confirmed, High.Apr 1 2019, 1:52 PM

I fixed related issues, let's me take a look.