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.
This commit is contained in:
Dalai Felinto 2017-04-25 18:43:53 +02:00
parent 973f4944e0
commit 00f5c621a6
3 changed files with 20 additions and 7 deletions

View File

@ -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

View File

@ -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;

View File

@ -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),