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:
Philipp Oeser 2019-07-02 10:50:31 +02:00
parent 5277557755
commit c6a199e254
Notes: blender-bot 2023-02-14 10:04:50 +01:00
Referenced by commit c252fe7a32, Transform: don't inspect all scene objects in poll
Referenced by issue #66311, crash when you use skin resize(ctrl+a) on two objects with multi edit, when skin modifier applyes only to one of objects
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) {
MVertSkin *vs = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MVERT_SKIN);
/* skin node size */
td->ext = tx;
copy_v3_v3(tx->isize, vs->radius);
tx->size = vs->radius;
td->val = vs->radius;
if (vs) {
/* skin node size */
td->ext = tx;
copy_v3_v3(tx->isize, vs->radius);
tx->size = vs->radius;
td->val = vs->radius;
}
else {
td->flag |= TD_SKIP;
}
}
else if (t->mode == TFM_SHRINKFATTEN) {
td->ext = tx;

View File

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