Fix T38234: changing smooth/flat shading on linked mesh data should not be allowed.

This commit is contained in:
Brecht Van Lommel 2014-01-15 16:01:40 +01:00
parent d9e52ac98b
commit 8c444958fc
Notes: blender-bot 2023-02-14 11:20:26 +01:00
Referenced by issue #38234, change smooth/flat of a linked mesh
1 changed files with 13 additions and 3 deletions

View File

@ -1341,13 +1341,20 @@ void OBJECT_OT_paths_clear(wmOperatorType *ot)
static int shade_smooth_exec(bContext *C, wmOperator *op)
{
ID *data;
Curve *cu;
Nurb *nu;
int clear = (strcmp(op->idname, "OBJECT_OT_shade_flat") == 0);
int done = FALSE;
bool done = false, linked_data = false;
CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
{
data = ob->data;
if (data && data->lib) {
linked_data = true;
continue;
}
if (ob->type == OB_MESH) {
BKE_mesh_smooth_flag_set(ob, !clear);
@ -1355,7 +1362,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
done = TRUE;
done = true;
}
else if (ELEM(ob->type, OB_SURF, OB_CURVE)) {
cu = ob->data;
@ -1368,11 +1375,14 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
done = TRUE;
done = true;
}
}
CTX_DATA_END;
if (linked_data)
BKE_report(op->reports, RPT_WARNING, "Can't edit linked mesh or curve data.");
return (done) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}