Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-02-26 08:30:07 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-02-26 08:31:11 +0300
commitb7939a059f9056ae57b4720a4c98dbe9025de407 (patch)
treea49b9ba8aec95dd6edd16ba2763f3e59ae525fe0
parent0c9607312f83fa3bbbabe245e97dbc96665f6e70 (diff)
Undo: use low level API calls to enable font edit-mode
While I couldn't redo a bug in this case, it's possible for the active object to become out of sync in rare cases, so best use these functions.
-rw-r--r--source/blender/editors/curve/editfont_undo.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/editors/curve/editfont_undo.c b/source/blender/editors/curve/editfont_undo.c
index 8f7eb19dfe8..a305a997d50 100644
--- a/source/blender/editors/curve/editfont_undo.c
+++ b/source/blender/editors/curve/editfont_undo.c
@@ -23,6 +23,8 @@
#include "MEM_guardedalloc.h"
+#include "CLG_log.h"
+
#include "BLI_array_utils.h"
#include "BLI_utildefines.h"
@@ -39,6 +41,7 @@
#include "ED_curve.h"
#include "ED_object.h"
+#include "ED_undo.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -53,6 +56,9 @@
# define ARRAY_CHUNK_SIZE 32
#endif
+/** Only needed this locally. */
+static CLG_LogRef LOG = {"ed.undo.font"};
+
/* -------------------------------------------------------------------- */
/** \name Undo Conversion
* \{ */
@@ -364,15 +370,22 @@ static void font_undosys_step_decode(struct bContext *C,
const eUndoStepDir UNUSED(dir),
bool UNUSED(is_final))
{
- /* TODO(campbell): undo_system: use low-level API to set mode. */
- ED_object_mode_set_ex(C, OB_MODE_EDIT, false, NULL);
- BLI_assert(font_undosys_poll(C));
FontUndoStep *us = (FontUndoStep *)us_p;
Object *obedit = us->obedit_ref.ptr;
+
+ /* Pass in an array of 1 (typically used for multi-object edit-mode). */
+ ED_undo_object_editmode_restore_helper(C, &obedit, 1, sizeof(Object *));
+
Curve *cu = obedit->data;
undofont_to_editfont(&us->data, cu);
DEG_id_tag_update(&obedit->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);
+
+ BLI_assert(font_undosys_poll(C));
+
cu->editfont->needs_flush_to_id = 1;
bmain->is_memfile_undo_flush_needed = true;
WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);