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>2020-09-12 06:38:12 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-09-12 06:42:32 +0300
commitad5f1d02318a30c545196f124e30504615294416 (patch)
tree32d9d75f581dfc83bb07d665eebaabe819ef0f24
parent77f6d9dbc999f87fc1dcb4974659bb3be75be639 (diff)
Fix T71605: Crash toggling dynamic topology in background mode
Support toggling without an undo stack in background mode.
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_dyntopo.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
index f07d22ed639..9b4b5b8d1e2 100644
--- a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
@@ -36,6 +36,7 @@
#include "BKE_brush.h"
#include "BKE_context.h"
+#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
@@ -58,6 +59,7 @@
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_sculpt.h"
+#include "ED_undo.h"
#include "ED_view3d.h"
#include "paint_intern.h"
#include "sculpt_intern.h"
@@ -285,11 +287,17 @@ void sculpt_dynamic_topology_disable_with_undo(Main *bmain,
Object *ob)
{
SculptSession *ss = ob->sculpt;
- if (ss->bm) {
- SCULPT_undo_push_begin("Dynamic topology disable");
- SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_END);
+ if (ss->bm != NULL) {
+ /* May be false in background mode. */
+ const bool use_undo = G.background ? (ED_undo_stack_get() != NULL) : true;
+ if (use_undo) {
+ SCULPT_undo_push_begin("Dynamic topology disable");
+ SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_END);
+ }
SCULPT_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, NULL);
- SCULPT_undo_push_end();
+ if (use_undo) {
+ SCULPT_undo_push_end();
+ }
}
}
@@ -300,10 +308,16 @@ static void sculpt_dynamic_topology_enable_with_undo(Main *bmain,
{
SculptSession *ss = ob->sculpt;
if (ss->bm == NULL) {
- SCULPT_undo_push_begin("Dynamic topology enable");
+ /* May be false in background mode. */
+ const bool use_undo = G.background ? (ED_undo_stack_get() != NULL) : true;
+ if (use_undo) {
+ SCULPT_undo_push_begin("Dynamic topology enable");
+ }
SCULPT_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob);
- SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN);
- SCULPT_undo_push_end();
+ if (use_undo) {
+ SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN);
+ SCULPT_undo_push_end();
+ }
}
}