Fix crash happening when clearing parent in outliner modes which doesn't support...
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 13 Aug 2013 14:46:39 +0000 (14:46 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 13 Aug 2013 14:46:39 +0000 (14:46 +0000)
source/blender/editors/space_outliner/outliner_edit.c
source/blender/editors/space_outliner/space_outliner.c

index a014724af4a0d5aa37abb5ffec18f7ed029b04a1..ed4ecff88b9dde578399068b66db26d3e868269c 100644 (file)
@@ -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;
index 00476cd467d1752c90a22562015f2be810ee0f11..874852ee320749b4e5e66c963c5e6381b0a11761 100644 (file)
@@ -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) {