From ceb645bc564f836bda3d87981a3d03c2ffc1419c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 5 Feb 2018 17:53:30 +1100 Subject: Fix T53986: Crash saving during sculpt stroke Also remove unused struct member. --- source/blender/blenkernel/BKE_paint.h | 1 - source/blender/editors/util/ed_util.c | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 8e7e69d22ca..de2c862651c 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -212,7 +212,6 @@ typedef struct SculptSession { /* Layer brush persistence between strokes */ float (*layer_co)[3]; /* Copy of the mesh vertices' locations */ - struct SculptStroke *stroke; struct StrokeCache *cache; union { diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 278b8e34311..c920c4524a1 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -168,7 +168,11 @@ bool ED_editors_flush_edits(const bContext *C, bool for_render) * exiting we might not have a context for edit object and multiple sculpt * objects can exist at the same time */ for (ob = bmain->object.first; ob; ob = ob->id.next) { - if (ob->mode & OB_MODE_SCULPT) { + if ((ob->mode & OB_MODE_SCULPT) && + /* Don't allow flushing while in the middle of a stroke (frees data in use). + * Auto-save prevents this from happening but scripts may cause a flush on saving: T53986. */ + ((ob->sculpt && ob->sculpt->cache) == 0)) + { /* flush multires changes (for sculpt) */ multires_force_update(ob); has_edited = true; -- cgit v1.2.3 From f911fb0744a8185745193a252b4115a6d7756102 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 5 Feb 2018 17:56:09 +1100 Subject: Minor change to last commit Keep mode checks simple, nest other checks in their body. --- source/blender/editors/util/ed_util.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'source') diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index c920c4524a1..b34605f6af3 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -168,23 +168,23 @@ bool ED_editors_flush_edits(const bContext *C, bool for_render) * exiting we might not have a context for edit object and multiple sculpt * objects can exist at the same time */ for (ob = bmain->object.first; ob; ob = ob->id.next) { - if ((ob->mode & OB_MODE_SCULPT) && - /* Don't allow flushing while in the middle of a stroke (frees data in use). - * Auto-save prevents this from happening but scripts may cause a flush on saving: T53986. */ - ((ob->sculpt && ob->sculpt->cache) == 0)) - { - /* flush multires changes (for sculpt) */ - multires_force_update(ob); - has_edited = true; - - if (for_render) { - /* flush changes from dynamic topology sculpt */ - BKE_sculptsession_bm_to_me_for_render(ob); - } - else { - /* Set reorder=false so that saving the file doesn't reorder - * the BMesh's elements */ - BKE_sculptsession_bm_to_me(ob, false); + if (ob->mode & OB_MODE_SCULPT) { + /* Don't allow flushing while in the middle of a stroke (frees data in use). + * Auto-save prevents this from happening but scripts may cause a flush on saving: T53986. */ + if ((ob->sculpt && ob->sculpt->cache) == 0) { + /* flush multires changes (for sculpt) */ + multires_force_update(ob); + has_edited = true; + + if (for_render) { + /* flush changes from dynamic topology sculpt */ + BKE_sculptsession_bm_to_me_for_render(ob); + } + else { + /* Set reorder=false so that saving the file doesn't reorder + * the BMesh's elements */ + BKE_sculptsession_bm_to_me(ob, false); + } } } else if (ob->mode & OB_MODE_EDIT) { -- cgit v1.2.3