Fix topbar tool UI being lost on undo

Using operators to the object mode was resetting the tool.

See: T56865
This commit is contained in:
Campbell Barton
2018-10-29 17:32:15 +11:00
parent cf1cf105a0
commit 0e268fb68b
3 changed files with 18 additions and 5 deletions

View File

@@ -217,6 +217,7 @@ bool ED_object_mode_compat_test(const struct Object *ob, eObjectMode mode);
bool ED_object_mode_compat_set(struct bContext *C, struct Object *ob, eObjectMode mode, struct ReportList *reports);
void ED_object_mode_toggle(struct bContext *C, eObjectMode mode);
void ED_object_mode_set(struct bContext *C, eObjectMode mode);
void ED_object_mode_exit(struct bContext *C);
bool ED_object_mode_generic_enter(
struct bContext *C,
@@ -229,10 +230,6 @@ bool ED_object_mode_generic_has_data(
struct Depsgraph *depsgraph,
struct Object *ob);
bool ED_object_mode_generic_exists(
struct wmWindowManager *wm, struct Object *ob,
eObjectMode object_mode);
/* object_modifier.c */
enum {
MODIFIER_APPLY_DATA = 1,

View File

@@ -38,6 +38,7 @@
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_report.h"
#include "BKE_layer.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -176,6 +177,21 @@ void ED_object_mode_set(bContext *C, eObjectMode mode)
wm->op_undo_depth--;
}
void ED_object_mode_exit(bContext *C)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
struct Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
FOREACH_OBJECT_BEGIN(view_layer, ob)
{
if (ob->mode & OB_MODE_ALL_MODE_DATA) {
ED_object_mode_generic_exit(bmain, depsgraph, scene, ob);
}
}
FOREACH_OBJECT_END;
}
/** \} */
/* -------------------------------------------------------------------- */

View File

@@ -83,7 +83,7 @@ static bool memfile_undosys_step_encode(struct bContext *C, UndoStep *us_p)
static void memfile_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNUSED(dir))
{
/* Loading the content will correctly switch into compatible non-object modes. */
ED_object_mode_set(C, OB_MODE_OBJECT);
ED_object_mode_exit(C);
MemFileUndoStep *us = (MemFileUndoStep *)us_p;
BKE_memfile_undo_decode(us->data, C);