Fix T66311: skin resize (ctrl+a) could crash

could happen when used on multiple objects with multi edit, and skin
modifier was not present on all participating objects

Reviewers: brecht

Maniphest Tasks: T66311

Differential Revision: https://developer.blender.org/D5165
This commit is contained in:
2019-07-02 10:50:31 +02:00
parent 5277557755
commit c6a199e254
2 changed files with 28 additions and 10 deletions

View File

@@ -2935,11 +2935,16 @@ static void VertsToTransData(TransInfo *t,
} }
else if (t->mode == TFM_SKIN_RESIZE) { else if (t->mode == TFM_SKIN_RESIZE) {
MVertSkin *vs = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MVERT_SKIN); MVertSkin *vs = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MVERT_SKIN);
/* skin node size */ if (vs) {
td->ext = tx; /* skin node size */
copy_v3_v3(tx->isize, vs->radius); td->ext = tx;
tx->size = vs->radius; copy_v3_v3(tx->isize, vs->radius);
td->val = vs->radius; tx->size = vs->radius;
td->val = vs->radius;
}
else {
td->flag |= TD_SKIP;
}
} }
else if (t->mode == TFM_SHRINKFATTEN) { else if (t->mode == TFM_SHRINKFATTEN) {
td->ext = tx; td->ext = tx;

View File

@@ -33,6 +33,7 @@
#include "BKE_global.h" #include "BKE_global.h"
#include "BKE_report.h" #include "BKE_report.h"
#include "BKE_editmesh.h" #include "BKE_editmesh.h"
#include "BKE_layer.h"
#include "BKE_scene.h" #include "BKE_scene.h"
#include "RNA_access.h" #include "RNA_access.h"
@@ -756,12 +757,24 @@ static void TRANSFORM_OT_resize(struct wmOperatorType *ot)
static bool skin_resize_poll(bContext *C) static bool skin_resize_poll(bContext *C)
{ {
struct Object *obedit = CTX_data_edit_object(C); uint objects_len = 0;
if (obedit && obedit->type == OB_MESH) { Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
BMEditMesh *em = BKE_editmesh_from_object(obedit); CTX_data_view_layer(C), CTX_wm_view3d(C), &objects_len);
return (em && CustomData_has_layer(&em->bm->vdata, CD_MVERT_SKIN));
bool ok = false;
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
if (obedit->type == OB_MESH) {
BMEditMesh *em = BKE_editmesh_from_object(obedit);
if (em && CustomData_has_layer(&em->bm->vdata, CD_MVERT_SKIN)) {
ok = true;
}
}
} }
return 0; MEM_freeN(objects);
return ok;
} }
static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot) static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot)