diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-06-28 22:39:39 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-06-28 22:39:39 +0400 |
commit | 24e8f2f4ce7c7cd5148c3c71b7d08ca1a6cd12fb (patch) | |
tree | e4cec480cd95102943ea3bd814c35aa036599d6c /source/blender/editors | |
parent | b6ffc681b1813ff0f13900a21b1c38d1055c0aef (diff) |
fix for crash linking fonts to other objects with linked obdata (link, undo would crash).
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/object/object_relations.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 4c652a82765..45773a2803c 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1430,12 +1430,13 @@ static int make_links_data_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); const int type = RNA_enum_get(op->ptr, "type"); Object *ob_src; - ID *id; + ID *obdata_id; int a; /* group */ LinkNode *ob_groups = NULL; - int is_cycle = FALSE; + bool is_cycle = false; + bool is_lib = false; ob_src = ED_object_active_context(C); @@ -1450,14 +1451,15 @@ static int make_links_data_exec(bContext *C, wmOperator *op) if (ob_src != ob_dst) { if (allow_make_links_data(type, ob_src, ob_dst)) { + obdata_id = ob_dst->data; + switch (type) { case MAKE_LINKS_OBDATA: /* obdata */ - id = ob_dst->data; - id->us--; + obdata_id->us--; - id = ob_src->data; - id_us_plus(id); - ob_dst->data = id; + obdata_id = ob_src->data; + id_us_plus(obdata_id); + ob_dst->data = obdata_id; /* if amount of material indices changed: */ test_object_materials(bmain, ob_dst->data); @@ -1473,6 +1475,10 @@ static int make_links_data_exec(bContext *C, wmOperator *op) break; case MAKE_LINKS_ANIMDATA: BKE_copy_animdata_id((ID *)ob_dst, (ID *)ob_src, FALSE); + if (obdata_id->lib) { + is_lib = true; + break; + } BKE_copy_animdata_id((ID *)ob_dst->data, (ID *)ob_src->data, FALSE); break; case MAKE_LINKS_GROUP: @@ -1508,6 +1514,11 @@ static int make_links_data_exec(bContext *C, wmOperator *op) Curve *cu_src = ob_src->data; Curve *cu_dst = ob_dst->data; + if (obdata_id->lib) { + is_lib = true; + break; + } + if (cu_dst->vfont) cu_dst->vfont->id.us--; cu_dst->vfont = cu_src->vfont; id_us_plus((ID *)cu_dst->vfont); @@ -1540,6 +1551,10 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } } + if (is_lib) { + BKE_report(op->reports, RPT_WARNING, "Skipped editing library object data"); + } + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C)); WM_event_add_notifier(C, NC_OBJECT, NULL); |