diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-04-25 19:43:53 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-04-25 19:44:17 +0300 |
commit | 00f5c621a65b6bc9847776b2542588835fb4054c (patch) | |
tree | 1b8c66395b8d8a94e85e2263a0e7a772ad03ee30 /source/blender/editors/space_outliner | |
parent | 973f4944e08c449d68b43edf39d9cb2d209f4b7a (diff) |
Outliner: Re-build depsgraph when reordering collections
Otherwise if we create a new collection, and drag a collection into it we either
get a crash, or at the very least we dont get the visibility flags correct.
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_intern.h | 4 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tree.c | 15 |
3 files changed, 20 insertions, 7 deletions
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 2256e55a315..06b37377535 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -39,6 +39,7 @@ struct wmOperatorType; struct TreeElement; struct TreeStoreElem; +struct Main; struct bContext; struct Scene; struct SceneLayer; @@ -68,7 +69,8 @@ typedef enum TreeTraversalAction { * Callback type for reinserting elements at a different position, used to allow user customizable element order. * Passing scene right now, may be better to allow some custom data. */ -typedef void (*TreeElementReinsertFunc)(const struct Scene *scene, struct TreeElement *insert_element, +typedef void (*TreeElementReinsertFunc)(struct Main *bmain, const struct Scene *scene, + struct TreeElement *insert_element, struct TreeElement *insert_handle, TreeElementInsertType action); /** * Executed on (almost) each mouse move while dragging. It's supposed to give info diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 90d27b09292..5466ef1a9ed 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -29,6 +29,7 @@ */ #include "BKE_context.h" +#include "BKE_main.h" #include "BLI_listbase.h" #include "BLI_math.h" @@ -164,7 +165,7 @@ static void outliner_item_drag_handle( te_dragged->drag_data->insert_handle = te_insert_handle; } -static bool outliner_item_drag_drop_apply(const Scene *scene, TreeElement *dragged_te) +static bool outliner_item_drag_drop_apply(Main *bmain, const Scene *scene, TreeElement *dragged_te) { TreeElement *insert_handle = dragged_te->drag_data->insert_handle; TreeElementInsertType insert_type = dragged_te->drag_data->insert_type; @@ -178,7 +179,7 @@ static bool outliner_item_drag_drop_apply(const Scene *scene, TreeElement *dragg /* call of assert above should not have changed insert_handle and insert_type at this point */ BLI_assert(dragged_te->drag_data->insert_handle == insert_handle && dragged_te->drag_data->insert_type == insert_type); - dragged_te->reinsert(scene, dragged_te, insert_handle, insert_type); + dragged_te->reinsert(bmain, scene, dragged_te, insert_handle, insert_type); return true; } @@ -187,6 +188,7 @@ static bool outliner_item_drag_drop_apply(const Scene *scene, TreeElement *dragg static int outliner_item_drag_drop_modal(bContext *C, wmOperator *op, const wmEvent *event) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); SpaceOops *soops = CTX_wm_space_outliner(C); @@ -198,7 +200,7 @@ static int outliner_item_drag_drop_modal(bContext *C, wmOperator *op, const wmEv switch (event->type) { case EVT_MODAL_MAP: if (event->val == OUTLINER_ITEM_DRAG_CONFIRM) { - if (outliner_item_drag_drop_apply(scene, te_dragged)) { + if (outliner_item_drag_drop_apply(bmain, scene, te_dragged)) { skip_rebuild = false; } retval = OPERATOR_FINISHED; diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 9cca2416acc..e7a866524fd 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -61,6 +61,7 @@ #include "BLT_translation.h" +#include "BKE_depsgraph.h" #include "BKE_fcurve.h" #include "BKE_main.h" #include "BKE_layer.h" @@ -389,7 +390,8 @@ static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *s } static void outliner_object_reorder( - const Scene *scene, TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action) + Main *UNUSED(bmain), const Scene *scene, + TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action) { TreeStoreElem *tselem_insert = TREESTORE(insert_element); Object *ob = (Object *)tselem_insert->id; @@ -413,6 +415,7 @@ static void outliner_object_reorder( } BKE_collection_object_move(scene, sc, sc_ob_parent, ob); } + static bool outliner_object_reorder_poll( const Scene *UNUSED(scene), const TreeElement *insert_element, TreeElement **io_insert_handle, TreeElementInsertType *io_action) @@ -1331,7 +1334,8 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops) } static void outliner_layer_collections_reorder( - const Scene *scene, TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action) + Main *bmain, const Scene *scene, + TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action) { LayerCollection *lc_insert = insert_element->directdata; LayerCollection *lc_handle = insert_handle->directdata; @@ -1348,6 +1352,8 @@ static void outliner_layer_collections_reorder( else { BLI_assert(0); } + + DAG_relations_tag_update(bmain); } static bool outliner_layer_collections_reorder_poll( const Scene *UNUSED(scene), const TreeElement *UNUSED(insert_element), @@ -1383,7 +1389,8 @@ static void outliner_add_collections_act_layer(SpaceOops *soops, SceneLayer *lay } static void outliner_scene_collections_reorder( - const Scene *scene, TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action) + Main *bmain, const Scene *scene, + TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action) { SceneCollection *sc_insert = insert_element->directdata; SceneCollection *sc_handle = insert_handle->directdata; @@ -1401,6 +1408,8 @@ static void outliner_scene_collections_reorder( else { BLI_assert(0); } + + DAG_relations_tag_update(bmain); } static bool outliner_scene_collections_reorder_poll( const Scene *scene, const TreeElement *UNUSED(insert_element), |