Sculpt save bug #46471

Closed
opened 2015-10-13 19:52:00 +02:00 by Alexey · 7 comments

System Information
Operating system and graphics card

Blender Version
Broken: (all)
Worked: (none)

Short description of error
1.png
2.png

Exact steps for others to reproduce the error
Leaf sculpt.blend1
open this file
draw anything(add any changes on model in sculpt mode)
try to close blender - we will not have this menu(message)

P.S. this error with sculpt mode only

**System Information** Operating system and graphics card **Blender Version** Broken: (all) Worked: (none) **Short description of error** ![1.png](https://archive.blender.org/developer/F244735/1.png) ![2.png](https://archive.blender.org/developer/F244737/2.png) **Exact steps for others to reproduce the error** [Leaf sculpt.blend1](https://archive.blender.org/developer/F244739/Leaf_sculpt.blend1) open this file draw anything(add any changes on model in sculpt mode) try to close blender - we will not have this menu(message) P.S. this error with sculpt mode only
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @Inwader77

Added subscriber: @Inwader77
Aaron Carlisle self-assigned this 2015-10-13 19:55:48 +02:00
Aaron Carlisle removed their assignment 2015-10-13 19:56:21 +02:00

Added subscribers: @ideasman42, @Sergey

Added subscribers: @ideasman42, @Sergey

Can confirm the issue. Here's a fix which solves it:

P269: Fix for #46471

diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index 2f1d4cd..5af6792 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -417,7 +417,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
 		MEM_freeN(nodes);
 	
 	/* end undo */
-	sculpt_undo_push_end();
+	sculpt_undo_push_end(C);
 
 	/* ensure that edges and faces get hidden as well (not used by
 	 * sculpt but it looks wrong when entering editmode otherwise) */
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 118f3a7..2f63146 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -133,7 +133,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
 	if (multires)
 		multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
 
-	sculpt_undo_push_end();
+	sculpt_undo_push_end(C);
 
 	if (nodes)
 		MEM_freeN(nodes);
@@ -265,7 +265,7 @@ int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *r
 	if (multires)
 		multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
 
-	sculpt_undo_push_end();
+	sculpt_undo_push_end(C);
 
 	ED_region_tag_redraw(ar);
 
@@ -420,7 +420,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
 		if (multires)
 			multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
 
-		sculpt_undo_push_end();
+		sculpt_undo_push_end(C);
 
 		ED_region_tag_redraw(vc.ar);
 		MEM_freeN((void *)mcords);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 07511e1..81c158a 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4522,7 +4522,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
 		sculpt_cache_free(ss->cache);
 		ss->cache = NULL;
 
-		sculpt_undo_push_end();
+		sculpt_undo_push_end(C);
 
 		BKE_pbvh_update(ss->pbvh, PBVH_UpdateOriginalBB, NULL);
 		
@@ -4846,7 +4846,7 @@ static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(o
 		sculpt_dynamic_topology_enable(C);
 		sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN);
 	}
-	sculpt_undo_push_end();
+	sculpt_undo_push_end(C);
 
 	return OPERATOR_FINISHED;
 }
@@ -5008,7 +5008,7 @@ static int sculpt_symmetrize_exec(bContext *C, wmOperator *UNUSED(op))
 
 	/* Finish undo */
 	BM_log_all_added(ss->bm, ss->bm_log);
-	sculpt_undo_push_end();
+	sculpt_undo_push_end(C);
 
 	/* Redraw */
 	sculpt_pbvh_clear(ob);
@@ -5216,7 +5216,7 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
 	}
 
 	MEM_freeN(nodes);
-	sculpt_undo_push_end();
+	sculpt_undo_push_end(C);
 
 	/* force rebuild of pbvh for better BB placement */
 	sculpt_pbvh_clear(ob);
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 8f1a465..51af878 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -118,7 +118,7 @@ typedef struct SculptUndoNode {
 SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType type);
 SculptUndoNode *sculpt_undo_get_node(PBVHNode *node);
 void sculpt_undo_push_begin(const char *name);
-void sculpt_undo_push_end(void);
+void sculpt_undo_push_end(const struct bContext *C);
 
 void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]);
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 1f1be51..6028f2c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -884,8 +884,9 @@ void sculpt_undo_push_begin(const char *name)
 	                         sculpt_undo_restore, sculpt_undo_free, sculpt_undo_cleanup);
 }
 
-void sculpt_undo_push_end(void)
+void sculpt_undo_push_end(const bContext *C)
 {
+	wmWindowManager *wm = CTX_wm_manager(C);
 	ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_MESH);
 	SculptUndoNode *unode;
 
@@ -901,4 +902,10 @@ void sculpt_undo_push_end(void)
 	}
 
 	ED_undo_paint_push_end(UNDO_PAINT_MESH);
+
+	/* TODO(sergey): Could this be de-duplicated with regular undo? */
+	if (wm->file_saved) {
+		wm->file_saved = 0;
+		WM_event_add_notifier(C, NC_WM | ND_DATACHANGED, NULL);
+	}
 }

@ideasman42, i'm kind of struggling about those few lines being duplicated across global undo and sculpt undo. Points:

  1. The code will need to be added to other local undo stacks
  2. It's few lines of code, could we really make meaningful function for them? Maybe call WM_tag_file_dirty(bContext *C)?
Can confirm the issue. Here's a fix which solves it: [P269: Fix for #46471](https://archive.blender.org/developer/P269.txt) ``` diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index 2f1d4cd..5af6792 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -417,7 +417,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) MEM_freeN(nodes); /* end undo */ - sculpt_undo_push_end(); + sculpt_undo_push_end(C); /* ensure that edges and faces get hidden as well (not used by * sculpt but it looks wrong when entering editmode otherwise) */ diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 118f3a7..2f63146 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -133,7 +133,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) if (multires) multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); - sculpt_undo_push_end(); + sculpt_undo_push_end(C); if (nodes) MEM_freeN(nodes); @@ -265,7 +265,7 @@ int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *r if (multires) multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); - sculpt_undo_push_end(); + sculpt_undo_push_end(C); ED_region_tag_redraw(ar); @@ -420,7 +420,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) if (multires) multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); - sculpt_undo_push_end(); + sculpt_undo_push_end(C); ED_region_tag_redraw(vc.ar); MEM_freeN((void *)mcords); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 07511e1..81c158a 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4522,7 +4522,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str sculpt_cache_free(ss->cache); ss->cache = NULL; - sculpt_undo_push_end(); + sculpt_undo_push_end(C); BKE_pbvh_update(ss->pbvh, PBVH_UpdateOriginalBB, NULL); @@ -4846,7 +4846,7 @@ static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(o sculpt_dynamic_topology_enable(C); sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); } - sculpt_undo_push_end(); + sculpt_undo_push_end(C); return OPERATOR_FINISHED; } @@ -5008,7 +5008,7 @@ static int sculpt_symmetrize_exec(bContext *C, wmOperator *UNUSED(op)) /* Finish undo */ BM_log_all_added(ss->bm, ss->bm_log); - sculpt_undo_push_end(); + sculpt_undo_push_end(C); /* Redraw */ sculpt_pbvh_clear(ob); @@ -5216,7 +5216,7 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op)) } MEM_freeN(nodes); - sculpt_undo_push_end(); + sculpt_undo_push_end(C); /* force rebuild of pbvh for better BB placement */ sculpt_pbvh_clear(ob); diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 8f1a465..51af878 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -118,7 +118,7 @@ typedef struct SculptUndoNode { SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType type); SculptUndoNode *sculpt_undo_get_node(PBVHNode *node); void sculpt_undo_push_begin(const char *name); -void sculpt_undo_push_end(void); +void sculpt_undo_push_end(const struct bContext *C); void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 1f1be51..6028f2c 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -884,8 +884,9 @@ void sculpt_undo_push_begin(const char *name) sculpt_undo_restore, sculpt_undo_free, sculpt_undo_cleanup); } -void sculpt_undo_push_end(void) +void sculpt_undo_push_end(const bContext *C) { + wmWindowManager *wm = CTX_wm_manager(C); ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_MESH); SculptUndoNode *unode; @@ -901,4 +902,10 @@ void sculpt_undo_push_end(void) } ED_undo_paint_push_end(UNDO_PAINT_MESH); + + /* TODO(sergey): Could this be de-duplicated with regular undo? */ + if (wm->file_saved) { + wm->file_saved = 0; + WM_event_add_notifier(C, NC_WM | ND_DATACHANGED, NULL); + } } ``` @ideasman42, i'm kind of struggling about those few lines being duplicated across global undo and sculpt undo. Points: 1. The code will need to be added to other local undo stacks 2. It's few lines of code, could we really make meaningful function for them? Maybe call `WM_tag_file_dirty(bContext *C)`?
Sergey Sharybin self-assigned this 2015-10-14 20:43:31 +02:00

Since this is using a global list anyway, its tempting to do this... (patch below)
However, using wm->first is weak, suggest to apply your patch, but move TODO(sergey): Could this be de-duplicated with regular undo? block into a function. WM_file_tag_modified ? - since we have other WM_file_* functions.

P270: #46471 hack

diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c
index 42f0aaa..73bde87 100644
--- a/source/blender/editors/sculpt_paint/paint_undo.c
+++ b/source/blender/editors/sculpt_paint/paint_undo.c
@@ -33,10 +33,15 @@
 #include "BLI_string.h"
 
 #include "DNA_userdef_types.h"
+#include "DNA_windowmanager_types.h"
 
 #include "BKE_blender.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
+#include "BKE_main.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
 
 #include "ED_paint.h"
 
@@ -287,6 +292,15 @@ void undo_paint_push_count_alloc(int type, int size)
 
 void ED_undo_paint_push_end(int type)
 {
+	/* XXX, this is called outside the main undo stack */
+	{
+		wmWindowManager *wm = G.main->wm.first;
+		if (wm->file_saved) {
+			wm->file_saved = 0;
+			WM_main_add_notifier(NC_WM | ND_DATACHANGED, NULL);
+		}
+	}
+
 	if (type == UNDO_PAINT_IMAGE)
 		undo_stack_push_end(&ImageUndoStack);
 	else if (type == UNDO_PAINT_MESH)

Since this is using a global list anyway, its tempting to do this... (patch below) However, using `wm->first` is weak, suggest to apply your patch, but move `TODO(sergey): Could this be de-duplicated with regular undo?` block into a function. `WM_file_tag_modified` ? - since we have other `WM_file_*` functions. [P270: #46471 hack](https://archive.blender.org/developer/P270.txt) ```diff diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c index 42f0aaa..73bde87 100644 --- a/source/blender/editors/sculpt_paint/paint_undo.c +++ b/source/blender/editors/sculpt_paint/paint_undo.c @@ -33,10 +33,15 @@ #include "BLI_string.h" #include "DNA_userdef_types.h" +#include "DNA_windowmanager_types.h" #include "BKE_blender.h" #include "BKE_context.h" #include "BKE_global.h" +#include "BKE_main.h" + +#include "WM_api.h" +#include "WM_types.h" #include "ED_paint.h" @@ -287,6 +292,15 @@ void undo_paint_push_count_alloc(int type, int size) void ED_undo_paint_push_end(int type) { + /* XXX, this is called outside the main undo stack */ + { + wmWindowManager *wm = G.main->wm.first; + if (wm->file_saved) { + wm->file_saved = 0; + WM_main_add_notifier(NC_WM | ND_DATACHANGED, NULL); + } + } + if (type == UNDO_PAINT_IMAGE) undo_stack_push_end(&ImageUndoStack); else if (type == UNDO_PAINT_MESH) ```

This issue was referenced by fd1487977b

This issue was referenced by fd1487977b0d1a24b2076e1bdf72b6102821e6e4

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#46471
No description provided.