Fix unnecessarily added undo steps when deleting only scene
Steps to reproduce were: startup.blend, move any object, delete active scene (nothing happens), undo (nothing happens), second undo is needed to revert object transformation
This commit is contained in:
parent
a662980f31
commit
5fafd493c2
|
@ -105,7 +105,7 @@ bScreen *ED_screen_add(struct wmWindow *win, struct Scene *scene, const char *na
|
|||
void ED_screen_set(struct bContext *C, struct bScreen *sc);
|
||||
void ED_screen_delete(struct bContext *C, struct bScreen *sc);
|
||||
void ED_screen_set_scene(struct bContext *C, struct bScreen *screen, struct Scene *scene);
|
||||
void ED_screen_delete_scene(struct bContext *C, struct Scene *scene);
|
||||
bool ED_screen_delete_scene(struct bContext *C, struct Scene *scene);
|
||||
void ED_screen_set_subwinactive(struct bContext *C, struct wmEvent *event);
|
||||
void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen);
|
||||
void ED_screen_animation_timer(struct bContext *C, int redraws, int refresh, int sync, int enable);
|
||||
|
|
|
@ -1707,8 +1707,11 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene)
|
|||
|
||||
}
|
||||
|
||||
/* only call outside of area/region loops */
|
||||
void ED_screen_delete_scene(bContext *C, Scene *scene)
|
||||
/**
|
||||
* \note Only call outside of area/region loops
|
||||
* \return true if successful
|
||||
*/
|
||||
bool ED_screen_delete_scene(bContext *C, Scene *scene)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *newscene;
|
||||
|
@ -1718,11 +1721,13 @@ void ED_screen_delete_scene(bContext *C, Scene *scene)
|
|||
else if (scene->id.next)
|
||||
newscene = scene->id.next;
|
||||
else
|
||||
return;
|
||||
return false;
|
||||
|
||||
ED_screen_set_scene(C, CTX_wm_screen(C), newscene);
|
||||
|
||||
BKE_scene_unlink(bmain, scene, newscene);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
|
||||
|
|
|
@ -3986,7 +3986,9 @@ static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
ED_screen_delete_scene(C, scene);
|
||||
if (ED_screen_delete_scene(C, scene) == false) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (G.debug & G_DEBUG)
|
||||
printf("scene delete %p\n", scene);
|
||||
|
|
|
@ -273,29 +273,40 @@ static EnumPropertyItem prop_scene_op_types[] = {
|
|||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static void outliner_do_scene_operation(
|
||||
static bool outliner_do_scene_operation(
|
||||
bContext *C, eOutliner_PropSceneOps event, ListBase *lb,
|
||||
void (*operation_cb)(bContext *, eOutliner_PropSceneOps, TreeElement *, TreeStoreElem *))
|
||||
bool (*operation_cb)(bContext *, eOutliner_PropSceneOps, TreeElement *, TreeStoreElem *))
|
||||
{
|
||||
TreeElement *te;
|
||||
TreeStoreElem *tselem;
|
||||
bool success = false;
|
||||
|
||||
for (te = lb->first; te; te = te->next) {
|
||||
tselem = TREESTORE(te);
|
||||
if (tselem->flag & TSE_SELECTED) {
|
||||
operation_cb(C, event, te, tselem);
|
||||
if (operation_cb(C, event, te, tselem)) {
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
static void scene_cb(bContext *C, eOutliner_PropSceneOps event, TreeElement *UNUSED(te), TreeStoreElem *tselem)
|
||||
static bool scene_cb(bContext *C, eOutliner_PropSceneOps event, TreeElement *UNUSED(te), TreeStoreElem *tselem)
|
||||
{
|
||||
Scene *scene = (Scene *)tselem->id;
|
||||
|
||||
if (event == OL_SCENE_OP_DELETE) {
|
||||
ED_screen_delete_scene(C, scene);
|
||||
WM_event_add_notifier(C, NC_SCENE | NA_REMOVED, scene);
|
||||
if (ED_screen_delete_scene(C, scene)) {
|
||||
WM_event_add_notifier(C, NC_SCENE | NA_REMOVED, scene);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int outliner_scene_operation_exec(bContext *C, wmOperator *op)
|
||||
|
@ -303,7 +314,9 @@ static int outliner_scene_operation_exec(bContext *C, wmOperator *op)
|
|||
SpaceOops *soops = CTX_wm_space_outliner(C);
|
||||
const eOutliner_PropSceneOps event = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
outliner_do_scene_operation(C, event, &soops->tree, scene_cb);
|
||||
if (outliner_do_scene_operation(C, event, &soops->tree, scene_cb) == false) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (event == OL_SCENE_OP_DELETE) {
|
||||
outliner_cleanup_tree(soops);
|
||||
|
|
Loading…
Reference in New Issue