Fix T71605: Crash toggling dynamic topology in background mode
Support toggling without an undo stack in background mode.
This commit is contained in:
parent
77f6d9dbc9
commit
ad5f1d0231
Notes:
blender-bot
2023-02-14 06:19:41 +01:00
Referenced by issue #71605, bpy.ops.sculpt.dynamic_topology_toggle causes a SegFault from Python in background mode
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue