Fix edit-mode undo leaving edit-mode with multiple windows

With two or more windows, edit-mode undo assumed it was
possible to load the undo state into the current scene.

When multiple windows are used this is not always the case.
Edit-mode undo steps now store the scene used to create them
which is used to read undo data back into this scene
(when it's shown in a window). Otherwise the current context is used.
This commit is contained in:
Campbell Barton
2023-10-27 11:39:49 +11:00
parent c50b682858
commit 585f43064a
11 changed files with 143 additions and 46 deletions

View File

@@ -184,6 +184,8 @@ struct ArmatureUndoStep_Elem {
struct ArmatureUndoStep {
UndoStep step;
/** See #ED_undo_object_editmode_validate_scene_from_windows code comment for details. */
UndoRefID_Scene scene_ref;
ArmatureUndoStep_Elem *elems;
uint elems_len;
};
@@ -199,11 +201,12 @@ static bool armature_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_
/* Important not to use the 3D view when getting objects because all objects
* outside of this list will be moved out of edit-mode when reading back undo steps. */
const Scene *scene = CTX_data_scene(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
Object **objects = ED_undo_editmode_objects_from_view_layer(scene, view_layer, &objects_len);
us->scene_ref.ptr = scene;
us->elems = static_cast<ArmatureUndoStep_Elem *>(
MEM_callocN(sizeof(*us->elems) * objects_len, __func__));
us->elems_len = objects_len;
@@ -229,9 +232,13 @@ static void armature_undosys_step_decode(
bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir /*dir*/, bool /*is_final*/)
{
ArmatureUndoStep *us = (ArmatureUndoStep *)us_p;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
ED_undo_object_editmode_validate_scene_from_windows(
CTX_wm_manager(C), us->scene_ref.ptr, &scene, &view_layer);
ED_undo_object_editmode_restore_helper(
C, &us->elems[0].obedit_ref.ptr, us->elems_len, sizeof(*us->elems));
scene, view_layer, &us->elems[0].obedit_ref.ptr, us->elems_len, sizeof(*us->elems));
BLI_assert(BKE_object_is_in_editmode(us->elems[0].obedit_ref.ptr));
@@ -254,10 +261,10 @@ static void armature_undosys_step_decode(
/* The first element is always active */
ED_undo_object_set_active_or_warn(
CTX_data_scene(C), CTX_data_view_layer(C), us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
scene, view_layer, us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
/* Check after setting active. */
BLI_assert(armature_undosys_poll(C));
/* Check after setting active (unless undoing into another scene). */
BLI_assert(armature_undosys_poll(C) || (scene != CTX_data_scene(C)));
bmain->is_memfile_undo_flush_needed = true;
@@ -281,6 +288,7 @@ static void armature_undosys_foreach_ID_ref(UndoStep *us_p,
{
ArmatureUndoStep *us = (ArmatureUndoStep *)us_p;
foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->scene_ref));
for (uint i = 0; i < us->elems_len; i++) {
ArmatureUndoStep_Elem *elem = &us->elems[i];
foreach_ID_ref_fn(user_data, ((UndoRefID *)&elem->obedit_ref));

View File

@@ -188,6 +188,8 @@ struct CurveUndoStep_Elem {
struct CurveUndoStep {
UndoStep step;
/** See #ED_undo_object_editmode_validate_scene_from_windows code comment for details. */
UndoRefID_Scene scene_ref;
CurveUndoStep_Elem *elems;
uint elems_len;
};
@@ -209,6 +211,7 @@ static bool curve_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p)
uint objects_len = 0;
Object **objects = ED_undo_editmode_objects_from_view_layer(scene, view_layer, &objects_len);
us->scene_ref.ptr = scene;
us->elems = static_cast<CurveUndoStep_Elem *>(
MEM_callocN(sizeof(*us->elems) * objects_len, __func__));
us->elems_len = objects_len;
@@ -234,9 +237,13 @@ static void curve_undosys_step_decode(
bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir /*dir*/, bool /*is_final*/)
{
CurveUndoStep *us = (CurveUndoStep *)us_p;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
ED_undo_object_editmode_validate_scene_from_windows(
CTX_wm_manager(C), us->scene_ref.ptr, &scene, &view_layer);
ED_undo_object_editmode_restore_helper(
C, &us->elems[0].obedit_ref.ptr, us->elems_len, sizeof(*us->elems));
scene, view_layer, &us->elems[0].obedit_ref.ptr, us->elems_len, sizeof(*us->elems));
BLI_assert(BKE_object_is_in_editmode(us->elems[0].obedit_ref.ptr));
@@ -260,10 +267,10 @@ static void curve_undosys_step_decode(
/* The first element is always active */
ED_undo_object_set_active_or_warn(
CTX_data_scene(C), CTX_data_view_layer(C), us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
scene, view_layer, us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
/* Check after setting active. */
BLI_assert(curve_undosys_poll(C));
/* Check after setting active (unless undoing into another scene). */
BLI_assert(curve_undosys_poll(C) || (scene != CTX_data_scene(C)));
bmain->is_memfile_undo_flush_needed = true;
@@ -287,6 +294,7 @@ static void curve_undosys_foreach_ID_ref(UndoStep *us_p,
{
CurveUndoStep *us = (CurveUndoStep *)us_p;
foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->scene_ref));
for (uint i = 0; i < us->elems_len; i++) {
CurveUndoStep_Elem *elem = &us->elems[i];
foreach_ID_ref_fn(user_data, ((UndoRefID *)&elem->obedit_ref));

View File

@@ -333,6 +333,8 @@ static Object *editfont_object_from_context(bContext *C)
struct FontUndoStep {
UndoStep step;
/** See #ED_undo_object_editmode_validate_scene_from_windows code comment for details. */
UndoRefID_Scene scene_ref;
/* NOTE: will split out into list for multi-object-editmode. */
UndoRefID_Object obedit_ref;
UndoFont data;
@@ -346,6 +348,7 @@ static bool font_undosys_poll(bContext *C)
static bool font_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p)
{
FontUndoStep *us = (FontUndoStep *)us_p;
us->scene_ref.ptr = CTX_data_scene(C);
us->obedit_ref.ptr = editfont_object_from_context(C);
Curve *cu = static_cast<Curve *>(us->obedit_ref.ptr->data);
undofont_from_editfont(&us->data, cu);
@@ -362,18 +365,22 @@ static void font_undosys_step_decode(
FontUndoStep *us = (FontUndoStep *)us_p;
Object *obedit = us->obedit_ref.ptr;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
/* Pass in an array of 1 (typically used for multi-object edit-mode). */
ED_undo_object_editmode_restore_helper(C, &obedit, 1, sizeof(Object *));
ED_undo_object_editmode_validate_scene_from_windows(
CTX_wm_manager(C), us->scene_ref.ptr, &scene, &view_layer);
ED_undo_object_editmode_restore_helper(scene, view_layer, &obedit, 1, sizeof(Object *));
Curve *cu = static_cast<Curve *>(obedit->data);
undofont_to_editfont(&us->data, cu);
DEG_id_tag_update(&cu->id, ID_RECALC_GEOMETRY);
ED_undo_object_set_active_or_warn(
CTX_data_scene(C), CTX_data_view_layer(C), obedit, us_p->name, &LOG);
ED_undo_object_set_active_or_warn(scene, view_layer, obedit, us_p->name, &LOG);
BLI_assert(font_undosys_poll(C));
/* Check after setting active (unless undoing into another scene). */
BLI_assert(font_undosys_poll(C) || (scene != CTX_data_scene(C)));
cu->editfont->needs_flush_to_id = 1;
bmain->is_memfile_undo_flush_needed = true;
@@ -391,6 +398,7 @@ static void font_undosys_foreach_ID_ref(UndoStep *us_p,
void *user_data)
{
FontUndoStep *us = (FontUndoStep *)us_p;
foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->scene_ref));
foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->obedit_ref));
}

View File

@@ -43,6 +43,8 @@ struct StepObject {
struct CurvesUndoStep {
UndoStep step;
/** See #ED_undo_object_editmode_validate_scene_from_windows code comment for details. */
UndoRefID_Scene scene_ref = {};
Array<StepObject> objects;
};
@@ -78,8 +80,13 @@ static void step_decode(
bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir /*dir*/, bool /*is_final*/)
{
CurvesUndoStep *us = reinterpret_cast<CurvesUndoStep *>(us_p);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
ED_undo_object_editmode_restore_helper(C,
ED_undo_object_editmode_validate_scene_from_windows(
CTX_wm_manager(C), us->scene_ref.ptr, &scene, &view_layer);
ED_undo_object_editmode_restore_helper(scene,
view_layer,
&us->objects.first().obedit_ref.ptr,
us->objects.size(),
sizeof(decltype(us->objects)::value_type));
@@ -95,11 +102,8 @@ static void step_decode(
DEG_id_tag_update(&curves_id.id, ID_RECALC_GEOMETRY);
}
ED_undo_object_set_active_or_warn(CTX_data_scene(C),
CTX_data_view_layer(C),
us->objects.first().obedit_ref.ptr,
us_p->name,
&LOG);
ED_undo_object_set_active_or_warn(
scene, view_layer, us->objects.first().obedit_ref.ptr, us_p->name, &LOG);
bmain->is_memfile_undo_flush_needed = true;
@@ -118,6 +122,7 @@ static void foreach_ID_ref(UndoStep *us_p,
{
CurvesUndoStep *us = reinterpret_cast<CurvesUndoStep *>(us_p);
foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->scene_ref));
for (const StepObject &object : us->objects) {
foreach_ID_ref_fn(user_data, ((UndoRefID *)&object.obedit_ref));
}

View File

@@ -21,6 +21,7 @@ struct ViewLayer;
struct bContext;
struct wmOperator;
struct wmOperatorType;
struct wmWindowManager;
/* undo.c */
@@ -72,10 +73,30 @@ bool ED_undo_is_memfile_compatible(const bContext *C);
*/
bool ED_undo_is_legacy_compatible_for_property(bContext *C, ID *id);
/**
* This function addresses the problem of restoring undo steps when multiple windows are used.
* Since undo steps don't track the full context that created them it's possible an edit-mode
* undo step will attempt to restore edit-mode into a different window, scene or view-layer.
*
* Values `scene_p` & `view_layer_p` (typically initialized from the context)
* are updated from the visible windows using `scene_ref` as a reference.
* If the no window can be found, the values are left as-is.
*
* Since users may close windows before undoing, it's expected the window may be unavailable.
* When this happens the edit-mode objects wont be restored into edit-mode by
* #ED_undo_object_editmode_restore_helper which is acceptable since objects
* which aren't visible in any window don't need to enter edit-mode.
*/
void ED_undo_object_editmode_validate_scene_from_windows(wmWindowManager *wm,
const Scene *scene_ref,
Scene **scene_p,
ViewLayer **view_layer_p);
/**
* Load all our objects from `object_array` into edit-mode, clear everything else.
*/
void ED_undo_object_editmode_restore_helper(bContext *C,
void ED_undo_object_editmode_restore_helper(Scene *scene,
ViewLayer *view_layer,
Object **object_array,
uint object_array_len,
uint object_array_stride);

View File

@@ -185,6 +185,8 @@ struct LatticeUndoStep_Elem {
struct LatticeUndoStep {
UndoStep step;
/** See #ED_undo_object_editmode_validate_scene_from_windows code comment for details. */
UndoRefID_Scene scene_ref;
LatticeUndoStep_Elem *elems;
uint elems_len;
};
@@ -200,11 +202,12 @@ static bool lattice_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p
/* Important not to use the 3D view when getting objects because all objects
* outside of this list will be moved out of edit-mode when reading back undo steps. */
const Scene *scene = CTX_data_scene(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
Object **objects = ED_undo_editmode_objects_from_view_layer(scene, view_layer, &objects_len);
us->scene_ref.ptr = scene;
us->elems = static_cast<LatticeUndoStep_Elem *>(
MEM_callocN(sizeof(*us->elems) * objects_len, __func__));
us->elems_len = objects_len;
@@ -230,9 +233,13 @@ static void lattice_undosys_step_decode(
bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir /*dir*/, bool /*is_final*/)
{
LatticeUndoStep *us = (LatticeUndoStep *)us_p;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
ED_undo_object_editmode_validate_scene_from_windows(
CTX_wm_manager(C), us->scene_ref.ptr, &scene, &view_layer);
ED_undo_object_editmode_restore_helper(
C, &us->elems[0].obedit_ref.ptr, us->elems_len, sizeof(*us->elems));
scene, view_layer, &us->elems[0].obedit_ref.ptr, us->elems_len, sizeof(*us->elems));
BLI_assert(BKE_object_is_in_editmode(us->elems[0].obedit_ref.ptr));
@@ -255,10 +262,10 @@ static void lattice_undosys_step_decode(
/* The first element is always active */
ED_undo_object_set_active_or_warn(
CTX_data_scene(C), CTX_data_view_layer(C), us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
scene, view_layer, us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
/* Check after setting active. */
BLI_assert(lattice_undosys_poll(C));
/* Check after setting active (unless undoing into another scene). */
BLI_assert(lattice_undosys_poll(C) || (scene != CTX_data_scene(C)));
bmain->is_memfile_undo_flush_needed = true;
@@ -282,6 +289,7 @@ static void lattice_undosys_foreach_ID_ref(UndoStep *us_p,
{
LatticeUndoStep *us = (LatticeUndoStep *)us_p;
foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->scene_ref));
for (uint i = 0; i < us->elems_len; i++) {
LatticeUndoStep_Elem *elem = &us->elems[i];
foreach_ID_ref_fn(user_data, ((UndoRefID *)&elem->obedit_ref));

View File

@@ -901,6 +901,8 @@ struct MeshUndoStep_Elem {
struct MeshUndoStep {
UndoStep step;
/** See #ED_undo_object_editmode_validate_scene_from_windows code comment for details. */
UndoRefID_Scene scene_ref;
MeshUndoStep_Elem *elems;
uint elems_len;
};
@@ -916,12 +918,13 @@ static bool mesh_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p)
/* Important not to use the 3D view when getting objects because all objects
* outside of this list will be moved out of edit-mode when reading back undo steps. */
const Scene *scene = CTX_data_scene(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
ToolSettings *ts = CTX_data_tool_settings(C);
const ToolSettings *ts = scene->toolsettings;
uint objects_len = 0;
Object **objects = ED_undo_editmode_objects_from_view_layer(scene, view_layer, &objects_len);
us->scene_ref.ptr = scene;
us->elems = static_cast<MeshUndoStep_Elem *>(
MEM_callocN(sizeof(*us->elems) * objects_len, __func__));
us->elems_len = objects_len;
@@ -965,9 +968,13 @@ static void mesh_undosys_step_decode(
bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir /*dir*/, bool /*is_final*/)
{
MeshUndoStep *us = (MeshUndoStep *)us_p;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
ED_undo_object_editmode_validate_scene_from_windows(
CTX_wm_manager(C), us->scene_ref.ptr, &scene, &view_layer);
ED_undo_object_editmode_restore_helper(
C, &us->elems[0].obedit_ref.ptr, us->elems_len, sizeof(*us->elems));
scene, view_layer, &us->elems[0].obedit_ref.ptr, us->elems_len, sizeof(*us->elems));
BLI_assert(BKE_object_is_in_editmode(us->elems[0].obedit_ref.ptr));
@@ -991,12 +998,11 @@ static void mesh_undosys_step_decode(
/* The first element is always active */
ED_undo_object_set_active_or_warn(
CTX_data_scene(C), CTX_data_view_layer(C), us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
scene, view_layer, us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
/* Check after setting active. */
BLI_assert(mesh_undosys_poll(C));
/* Check after setting active (unless undoing into another scene). */
BLI_assert(mesh_undosys_poll(C) || (scene != CTX_data_scene(C)));
Scene *scene = CTX_data_scene(C);
scene->toolsettings->selectmode = us->elems[0].data.selectmode;
scene->toolsettings->uv_selectmode = us->elems[0].data.uv_selectmode;
@@ -1022,6 +1028,7 @@ static void mesh_undosys_foreach_ID_ref(UndoStep *us_p,
{
MeshUndoStep *us = (MeshUndoStep *)us_p;
foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->scene_ref));
for (uint i = 0; i < us->elems_len; i++) {
MeshUndoStep_Elem *elem = &us->elems[i];
foreach_ID_ref_fn(user_data, ((UndoRefID *)&elem->obedit_ref));

View File

@@ -141,6 +141,8 @@ struct MBallUndoStep_Elem {
struct MBallUndoStep {
UndoStep step;
/** See #ED_undo_object_editmode_validate_scene_from_windows code comment for details. */
UndoRefID_Scene scene_ref;
MBallUndoStep_Elem *elems;
uint elems_len;
};
@@ -156,11 +158,12 @@ static bool mball_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p)
/* Important not to use the 3D view when getting objects because all objects
* outside of this list will be moved out of edit-mode when reading back undo steps. */
const Scene *scene = CTX_data_scene(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
Object **objects = ED_undo_editmode_objects_from_view_layer(scene, view_layer, &objects_len);
us->scene_ref.ptr = scene;
us->elems = static_cast<MBallUndoStep_Elem *>(
MEM_callocN(sizeof(*us->elems) * objects_len, __func__));
us->elems_len = objects_len;
@@ -186,10 +189,13 @@ static void mball_undosys_step_decode(
bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir /*dir*/, bool /*is_final*/)
{
MBallUndoStep *us = (MBallUndoStep *)us_p;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
ED_undo_object_editmode_validate_scene_from_windows(
CTX_wm_manager(C), us->scene_ref.ptr, &scene, &view_layer);
ED_undo_object_editmode_restore_helper(
C, &us->elems[0].obedit_ref.ptr, us->elems_len, sizeof(*us->elems));
scene, view_layer, &us->elems[0].obedit_ref.ptr, us->elems_len, sizeof(*us->elems));
BLI_assert(BKE_object_is_in_editmode(us->elems[0].obedit_ref.ptr));
for (uint i = 0; i < us->elems_len; i++) {
@@ -211,10 +217,10 @@ static void mball_undosys_step_decode(
/* The first element is always active */
ED_undo_object_set_active_or_warn(
CTX_data_scene(C), CTX_data_view_layer(C), us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
scene, view_layer, us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
/* Check after setting active. */
BLI_assert(mball_undosys_poll(C));
/* Check after setting active (unless undoing into another scene). */
BLI_assert(mball_undosys_poll(C) || (scene != CTX_data_scene(C)));
bmain->is_memfile_undo_flush_needed = true;
@@ -238,6 +244,7 @@ static void mball_undosys_foreach_ID_ref(UndoStep *us_p,
{
MBallUndoStep *us = (MBallUndoStep *)us_p;
foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->scene_ref));
for (uint i = 0; i < us->elems_len; i++) {
MBallUndoStep_Elem *elem = &us->elems[i];
foreach_ID_ref_fn(user_data, ((UndoRefID *)&elem->obedit_ref));

View File

@@ -203,6 +203,7 @@ static void undoptcache_free_data(PTCacheUndo *undo)
struct ParticleUndoStep {
UndoStep step;
/** See #ED_undo_object_editmode_validate_scene_from_windows code comment for details. */
UndoRefID_Scene scene_ref;
UndoRefID_Object object_ref;
PTCacheUndo data;
@@ -240,8 +241,14 @@ static void particle_undosys_step_decode(
ParticleUndoStep *us = (ParticleUndoStep *)us_p;
Scene *scene = us->scene_ref.ptr;
Object *ob = us->object_ref.ptr;
ViewLayer *view_layer = CTX_data_view_layer(C);
/* Only to correct the `view_layer` which might not match the scene
* (in the case of undoing with multiple windows). */
ED_undo_object_editmode_validate_scene_from_windows(
CTX_wm_manager(C), us->scene_ref.ptr, &scene, &view_layer);
Object *ob = us->object_ref.ptr;
ED_object_particle_edit_mode_enter_ex(depsgraph, scene, ob);
PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
@@ -261,9 +268,10 @@ static void particle_undosys_step_decode(
}
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
ED_undo_object_set_active_or_warn(scene, CTX_data_view_layer(C), ob, us_p->name, &LOG);
ED_undo_object_set_active_or_warn(scene, view_layer, ob, us_p->name, &LOG);
BLI_assert(particle_undosys_poll(C));
/* Check after setting active (unless undoing into another scene). */
BLI_assert(particle_undosys_poll(C) || (scene != CTX_data_scene(C)));
}
static void particle_undosys_step_free(UndoStep *us_p)

View File

@@ -1835,7 +1835,8 @@ static void sculpt_undo_set_active_layer(bContext *C, SculptAttrRef *attr)
* domain and just unconvert it.
*/
if (!layer) {
layer = BKE_id_attribute_search_for_write(&me->id, attr->name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
layer = BKE_id_attribute_search_for_write(
&me->id, attr->name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
if (layer) {
if (ED_geometry_attribute_convert(
me, attr->name, eCustomDataType(attr->type), attr->domain, nullptr))

View File

@@ -826,14 +826,30 @@ void ED_undo_object_set_active_or_warn(
}
}
void ED_undo_object_editmode_restore_helper(bContext *C,
void ED_undo_object_editmode_validate_scene_from_windows(wmWindowManager *wm,
const Scene *scene_ref,
Scene **scene_p,
ViewLayer **view_layer_p)
{
if (*scene_p == scene_ref) {
return;
}
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (win->scene == scene_ref) {
*scene_p = win->scene;
*view_layer_p = WM_window_get_active_view_layer(win);
return;
}
}
}
void ED_undo_object_editmode_restore_helper(Scene *scene,
ViewLayer *view_layer,
Object **object_array,
uint object_array_len,
uint object_array_stride)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Main *bmain = G_MAIN;
uint bases_len = 0;
/* Don't request unique data because we want to de-select objects when exiting edit-mode
* for that to be done on all objects we can't skip ones that share data. */