[Bf-blender-cvs] [985712e5ee1] master: Fix loading a file saved w/ dyntopo
Campbell Barton
noreply at git.blender.org
Fri Jan 18 14:53:32 CET 2019
Commit: 985712e5ee178789dbdf9124a896252db042ba50
Author: Campbell Barton
Date: Fri Jan 18 23:15:22 2019 +1100
Branches: master
https://developer.blender.org/rB985712e5ee178789dbdf9124a896252db042ba50
Fix loading a file saved w/ dyntopo
Ensure ED_editors_init doesn't create any undo steps
before the initial memfile undo is written.
===================================================================
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/util/ed_util.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index e315f88836a..e72b5490f8a 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5739,11 +5739,18 @@ void ED_object_sculptmode_enter_ex(
}
if (message_unsupported == NULL) {
+ /* Needed because we may be entering this mode before the undo system loads. */
+ wmWindowManager *wm = bmain->wm.first;
+ bool has_undo = wm->undo_stack != NULL;
/* undo push is needed to prevent memory leak */
- sculpt_undo_push_begin("Dynamic topology enable");
+ if (has_undo) {
+ sculpt_undo_push_begin("Dynamic topology enable");
+ }
sculpt_dynamic_topology_enable_ex(depsgraph, scene, ob);
- sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN);
- sculpt_undo_push_end();
+ if (has_undo) {
+ sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN);
+ sculpt_undo_push_end();
+ }
}
else {
BKE_reportf(reports, RPT_WARNING,
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index abc4f20ac71..3bd87314c12 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -95,16 +95,15 @@ void ED_editors_init(bContext *C)
Scene *scene = CTX_data_scene(C);
wmWindowManager *wm = CTX_wm_manager(C);
- if (wm->undo_stack == NULL) {
- wm->undo_stack = BKE_undosys_stack_create();
- }
-
/* This is called during initialization, so we don't want to store any reports */
ReportList *reports = CTX_wm_reports(C);
int reports_flag_prev = reports->flag & ~RPT_STORE;
SWAP(int, reports->flag, reports_flag_prev);
+ /* Don't do undo pushes when calling an operator. */
+ wm->op_undo_depth++;
+
/* toggle on modes for objects that were saved with these enabled. for
* e.g. linked objects we have to ensure that they are actually the
* active object in this scene. */
@@ -177,6 +176,7 @@ void ED_editors_init(bContext *C)
}
SWAP(int, reports->flag, reports_flag_prev);
+ wm->op_undo_depth--;
}
/* frees all editmode stuff */
More information about the Bf-blender-cvs
mailing list