Fix T46456: Crash when aborting stroke while using dyntopo.
[blender.git] / source / blender / editors / sculpt_paint / sculpt.c
index 73f829ada7194c309f8f96decb5d2d141680a97c..7cc70418fe7469de871d3991d8fe6b5addeddafa 100644 (file)
@@ -4817,8 +4817,11 @@ static void sculpt_brush_stroke_cancel(bContext *C, wmOperator *op)
        Object *ob = CTX_data_active_object(C);
        SculptSession *ss = ob->sculpt;
        Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+       const Brush *brush = BKE_paint_brush(&sd->paint);
 
-       if (ss->cache) {
+       /* XXX Cancelling strokes that way does not work with dynamic topology, user will have to do real undo for now.
+        *     See T46456. */
+       if (ss->cache && !sculpt_stroke_is_dynamic_topology(ss, brush)) {
                paint_mesh_restore_co(sd, ob);
        }