[Bf-blender-cvs] [585d2f3] master: Fix T32209 quitting not saving latest data if you are in edit or sculpt mode on quit.blend.

Antony Riakiotakis noreply at git.blender.org
Fri Oct 10 12:04:52 CEST 2014


Commit: 585d2f31a9c438bddb63842b2f160236323e355b
Author: Antony Riakiotakis
Date:   Fri Oct 10 11:48:48 2014 +0200
Branches: master
https://developer.blender.org/rB585d2f31a9c438bddb63842b2f160236323e355b

Fix T32209 quitting not saving latest data if you are in edit or sculpt mode on
quit.blend.

This will use a slower file write if an object is in edit or sculpt
mode.

Autosaving will explicitly not be supported to keep it fast.
Added a tooltip warning.

===================================================================

M	source/blender/editors/include/ED_util.h
M	source/blender/editors/util/ed_util.c
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/windowmanager/intern/wm_init_exit.c

===================================================================

diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index 6d9f1c4..e26e034 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -46,7 +46,7 @@ struct Mesh;
 void    ED_editors_init(struct bContext *C);
 void    ED_editors_exit(struct bContext *C);
 
-void    ED_editors_flush_edits(const struct bContext *C, bool for_render);
+bool    ED_editors_flush_edits(const struct bContext *C, bool for_render);
 
 /* ************** Undo ************************ */
 
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 56b12fc..ec0471d 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -153,19 +153,20 @@ void ED_editors_exit(bContext *C)
 
 /* flush any temp data from object editing to DNA before writing files,
  * rendering, copying, etc. */
-void ED_editors_flush_edits(const bContext *C, bool for_render)
+bool ED_editors_flush_edits(const bContext *C, bool for_render)
 {
+	bool has_edited = false;
 	Object *ob;
-	Object *obedit = CTX_data_edit_object(C);
 	Main *bmain = CTX_data_main(C);
-	/* get editmode results */
-	if (obedit)
-		ED_object_editmode_load(obedit);
 
+	/* loop through all data to find edit mode or object mode, because during
+	 * 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 && (ob->mode & OB_MODE_SCULPT)) {
+		if (ob->mode & OB_MODE_SCULPT) {
 			/* flush multires changes (for sculpt) */
 			multires_force_update(ob);
+			has_edited = true;
 
 			if (for_render) {
 				/* flush changes from dynamic topology sculpt */
@@ -177,7 +178,14 @@ void ED_editors_flush_edits(const bContext *C, bool for_render)
 				BKE_sculptsession_bm_to_me(ob, false);
 			}
 		}
+		else if (ob->mode & OB_MODE_EDIT) {
+			/* get editmode results */
+			has_edited = true;
+			ED_object_editmode_load(ob);
+		}
 	}
+
+	return has_edited;
 }
 
 /* ***** XXX: functions are using old blender names, cleanup later ***** */
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 7fdc9ba..b496833 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -4388,7 +4388,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
 	prop = RNA_def_property(srna, "use_auto_save_temporary_files", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_AUTOSAVE);
 	RNA_def_property_ui_text(prop, "Auto Save Temporary Files",
-	                         "Automatic saving of temporary files in temp directory, uses process ID");
+	                         "Automatic saving of temporary files in temp directory, uses process ID (Sculpt or edit mode data won't be saved!')");
 	RNA_def_property_update(prop, 0, "rna_userdef_autosave_update");
 
 	prop = RNA_def_property(srna, "auto_save_time", PROP_INT, PROP_NONE);
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 20f5f8d..00e25d3 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -54,6 +54,8 @@
 #include "BLI_threads.h"
 #include "BLI_utildefines.h"
 
+#include "BLO_writefile.h"
+
 #include "BKE_blender.h"
 #include "BKE_context.h"
 #include "BKE_screen.h"
@@ -409,11 +411,18 @@ void WM_exit_ext(bContext *C, const bool do_python)
 			if ((U.uiflag2 & USER_KEEP_SESSION) || BKE_undo_valid(NULL)) {
 				/* save the undo state as quit.blend */
 				char filename[FILE_MAX];
-				
+				bool has_edited;
+				int fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN | G_FILE_HISTORY);
+
 				BLI_make_file_string("/", filename, BLI_temp_dir_base(), BLENDER_QUIT_FILE);
 
-				if (BKE_undo_save_file(filename))
-					printf("Saved session recovery to '%s'\n", filename);
+				has_edited = ED_editors_flush_edits(C, false);
+
+				if ((has_edited && BLO_write_file(CTX_data_main(C), filename, fileflags, NULL, NULL)) ||
+					BKE_undo_save_file(filename))
+				{
+						printf("Saved session recovery to '%s'\n", filename);
+				}
 			}
 		}




More information about the Bf-blender-cvs mailing list