diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-08-13 18:46:39 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-08-13 18:46:39 +0400 |
commit | 135ee563e94b064ba4d4524a5a25c1c7b3964519 (patch) | |
tree | 94043ed413f20fb8ccbceb3615c2d45e873a0b8a /source/blender/editors/space_outliner | |
parent | 5096beb4a56f601c696aeab5e19c8e171a9b6cb3 (diff) |
Fix crash happening when clearing parent in outliner modes which doesn't support this.
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_edit.c | 19 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/space_outliner.c | 4 |
2 files changed, 16 insertions, 7 deletions
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index a014724af4a..ed4ecff88b9 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1648,6 +1648,17 @@ void OUTLINER_OT_parent_drop(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", prop_make_parent_types, 0, "Type", ""); } +static int outliner_parenting_poll(bContext *C) +{ + SpaceOops *soops = CTX_wm_space_outliner(C); + + if (soops) { + return ELEM4(soops->outlinevis, SO_ALL_SCENES, SO_CUR_SCENE, SO_VISIBLE, SO_GROUPS); + } + + return FALSE; +} + static int parent_clear_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { Main *bmain = CTX_data_main(C); @@ -1662,12 +1673,6 @@ static int parent_clear_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE /* search forwards to find the object */ te = outliner_find_id(soops, &soops->tree, (ID *)ob); - /* then search backwards to get the scene */ - scene = (Scene *)outliner_search_back(soops, te, ID_SCE); - - if (scene == NULL) { - return OPERATOR_CANCELLED; - } ED_object_parent_clear(ob, RNA_enum_get(op->ptr, "type")); @@ -1687,7 +1692,7 @@ void OUTLINER_OT_parent_clear(wmOperatorType *ot) /* api callbacks */ ot->invoke = parent_clear_invoke; - ot->poll = ED_operator_outliner_active; + ot->poll = outliner_parenting_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 00476cd467d..874852ee320 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -144,6 +144,10 @@ static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent * UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); + if (!ELEM4(soops->outlinevis, SO_ALL_SCENES, SO_CUR_SCENE, SO_VISIBLE, SO_GROUPS)) { + return FALSE; + } + if (drag->type == WM_DRAG_ID) { ID *id = (ID *)drag->poin; if (GS(id->name) == ID_OB) { |