maybe there could be some macro's or functions OB_MATERIAL_OK(ob), OB_MODIFIER_OK(ob)
in this code it looks like your could link modifiers to an armature & camera too. On Tue, Jun 8, 2010 at 10:24 PM, Diego Borghetti <[email protected]> wrote: > Revision: 29346 > > http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29346 > Author: bdiego > Date: 2010-06-08 22:24:28 +0200 (Tue, 08 Jun 2010) > > Log Message: > ----------- > Fix #22534 linking object data for two forces results in crash. > > This is because the make_links_data_exec don't check for the > object type like before, so try to access the obdata of an empty > and blender crash. > > The solution is not the best, we have a new function > allow_make_links_data to check if we can links data from one > object to another. > > The real solution is build the menu like the 2.4x, so only > show the options that we allow for the object type that > we have select/active. > > Matt, any suggestion ? > > Modified Paths: > -------------- > trunk/blender/source/blender/editors/object/object_relations.c > > Modified: trunk/blender/source/blender/editors/object/object_relations.c > =================================================================== > --- trunk/blender/source/blender/editors/object/object_relations.c > 2010-06-08 17:10:52 UTC (rev 29345) > +++ trunk/blender/source/blender/editors/object/object_relations.c > 2010-06-08 20:24:28 UTC (rev 29346) > @@ -1188,6 +1188,29 @@ > MAKE_LINKS_MODIFIERS > }; > > +/* Return 1 if make link data is allow, zero otherwise */ > +static int allow_make_links_data(int ev, Object *ob, Object *obt) > +{ > + if (ev == MAKE_LINKS_OBDATA) { > + if (ob->type == OB_MESH && obt->type == OB_MESH) > + return(1); > + } > + else if (ev == MAKE_LINKS_MATERIALS) { > + if ((ob->type == OB_MESH || ob->type == OB_CURVE || ob->type > == OB_FONT || ob->type == OB_SURF || ob->type == OB_MBALL) && > + (obt->type == OB_MESH || obt->type == OB_CURVE || > obt->type == OB_FONT || obt->type == OB_SURF || obt->type == OB_MBALL)) > + return(1); > + } > + else if (ev == MAKE_LINKS_ANIMDATA) > + return(1); > + else if (ev == MAKE_LINKS_DUPLIGROUP) > + return(1); > + else if (ev == MAKE_LINKS_MODIFIERS) { > + if (ob->type != OB_EMPTY && obt->type != OB_EMPTY) > + return(1); > + } > + return(0); > +} > + > static int make_links_data_exec(bContext *C, wmOperator *op) > { > int event = RNA_int_get(op->ptr, "type"); > @@ -1199,43 +1222,45 @@ > > CTX_DATA_BEGIN(C, Object*, obt, selected_editable_objects) { > if(ob != obt) { > - switch(event) { > - case MAKE_LINKS_OBDATA: /* obdata */ > - id= obt->data; > - id->us--; > + if (allow_make_links_data(event, ob, obt)) { > + switch(event) { > + case MAKE_LINKS_OBDATA: /* obdata */ > + id= obt->data; > + id->us--; > > - id= ob->data; > - id_us_plus(id); > - obt->data= id; > + id= ob->data; > + id_us_plus(id); > + obt->data= id; > > - /* if amount of material indices changed: */ > - test_object_materials(obt->data); > + /* if amount of material indices > changed: */ > + test_object_materials(obt->data); > > - obt->recalc |= OB_RECALC_DATA; > - break; > - case MAKE_LINKS_MATERIALS: > - /* new approach, using functions from kernel > */ > - for(a=0; a<ob->totcol; a++) { > - Material *ma= > give_current_material(ob, a+1); > - assign_material(obt, ma, a+1); /* > also works with ma==NULL */ > + obt->recalc |= OB_RECALC_DATA; > + break; > + case MAKE_LINKS_MATERIALS: > + /* new approach, using functions from > kernel */ > + for(a=0; a<ob->totcol; a++) { > + Material *ma= > give_current_material(ob, a+1); > + assign_material(obt, ma, > a+1); /* also works with ma==NULL */ > + } > + break; > + case MAKE_LINKS_ANIMDATA: > + BKE_copy_animdata_id((ID *)obt, (ID > *)ob); > + BKE_copy_animdata_id((ID *)obt->data, > (ID *)ob->data); > + break; > + case MAKE_LINKS_DUPLIGROUP: > + if(ob->dup_group) > ob->dup_group->id.us--; > + obt->dup_group= ob->dup_group; > + if(obt->dup_group) { > + id_us_plus((ID > *)obt->dup_group); > + obt->transflag |= > OB_DUPLIGROUP; > + } > + break; > + case MAKE_LINKS_MODIFIERS: > + object_link_modifiers(obt, ob); > + obt->recalc |= OB_RECALC; > + break; > } > - break; > - case MAKE_LINKS_ANIMDATA: > - BKE_copy_animdata_id((ID *)obt, (ID *)ob); > - BKE_copy_animdata_id((ID *)obt->data, (ID > *)ob->data); > - break; > - case MAKE_LINKS_DUPLIGROUP: > - if(ob->dup_group) ob->dup_group->id.us--; > - obt->dup_group= ob->dup_group; > - if(obt->dup_group) { > - id_us_plus((ID *)obt->dup_group); > - obt->transflag |= OB_DUPLIGROUP; > - } > - break; > - case MAKE_LINKS_MODIFIERS: > - object_link_modifiers(obt, ob); > - obt->recalc |= OB_RECALC; > - break; > } > } > } > > > _______________________________________________ > Bf-blender-cvs mailing list > [email protected] > http://lists.blender.org/mailman/listinfo/bf-blender-cvs > -- - Campbell _______________________________________________ Bf-committers mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-committers
