From 2036a2638e3abf0d4cd3e494ede0babf0b8febbf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 16 Feb 2010 16:32:25 +0000 Subject: [#21182] Make proxy for object without group crash Blender. from Banlu Kemiyatorn (suchness), modified with more error messages. --- source/blender/editors/object/object_relations.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index b9713ca15c2..46cf914755d 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -302,12 +302,23 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) static int make_proxy_exec (bContext *C, wmOperator *op) { - Object *ob, *gob= CTX_data_active_object(C); - GroupObject *go= BLI_findlink(&gob->dup_group->gobject, RNA_enum_get(op->ptr, "type")); + Object *ob, *gob; + GroupObject *go; Scene *scene= CTX_data_scene(C); - ob= go->ob; - if (ob) { + if(!(gob=CTX_data_active_object(C))) { + BKE_report(op->reports, RPT_ERROR, "No active object"); + return OPERATOR_CANCELLED; + } else if(gob->dup_group==NULL) { + BKE_report(op->reports, RPT_ERROR, "Active obhect has no dupligroup"); + return OPERATOR_CANCELLED; + } else if(!(go= BLI_findlink(&gob->dup_group->gobject, RNA_enum_get(op->ptr, "type")))) { + BKE_report(op->reports, RPT_ERROR, "Active objects dupligroup could not be found"); + return OPERATOR_CANCELLED; + } else if (!(ob= go->ob)) { + BKE_report(op->reports, RPT_ERROR, "Group has no object to make the proxy with"); + return OPERATOR_CANCELLED; + } else { Object *newob; Base *newbase, *oldbase= BASACT; char name[32]; @@ -339,10 +350,6 @@ static int make_proxy_exec (bContext *C, wmOperator *op) DAG_id_flush_update(&newob->id, OB_RECALC); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, newob); } - else { - BKE_report(op->reports, RPT_ERROR, "No object to make proxy for"); - return OPERATOR_CANCELLED; - } return OPERATOR_FINISHED; } -- cgit v1.2.3